コード例 #1
0
ファイル: kn_stream_socket.c プロジェクト: ifzz/distri.lua
static void on_events(handle_t h,int events){	
	kn_socket *s = (kn_socket*)h;
	if(h->status == SOCKET_CLOSE)
		return;
	do{
		h->inloop = 1;
		if(h->status == SOCKET_LISTENING){
			process_accept(s);
		}else if(h->status == SOCKET_CONNECTING){
			process_connect(s,events);
		}else if(h->status == SOCKET_ESTABLISH){
			if(events & EVENT_READ){
				process_read(s);	
				if(h->status == SOCKET_CLOSE) 
					break;								
				
			}		
			if(events & EVENT_WRITE)
				process_write(s);			
		}
		h->inloop = 0;
	}while(0);
	if(h->status == SOCKET_CLOSE)
		on_destroy(s);
}
コード例 #2
0
ファイル: access_byid.cpp プロジェクト: GreatStone/terark-db
void AccessByNameID<void*>::remove(uintptr_t id, const std::string& name)
{
	void* p = m_byid.get_ptr(id);
	m_byid.free_id(id);
	m_byname->erase(name);
	on_destroy(p);
}
コード例 #3
0
ファイル: main.cpp プロジェクト: vadmium/aot
LRESULT CALLBACK wnd_proc(HWND hw, UINT msg, WPARAM wp, LPARAM lp) {
    switch(msg)
    {
    case WM_CREATE:
        return on_create(hw);

    case WM_DESTROY:
        on_destroy(hw);
        break;

    case WM_CLOSE:
        on_close(hw);
        return 0;

    case WM_NOTIFY_ICON:
        return on_notify_icon(hw, lp);

        //~ case WM_COMMAND:
        //~ switch(LOWORD(wp))
        //~ {
        //~ case IDM_EXIT:
        //~ on_exit(hw);
        //~ break;
        //~ }
        //~ return 0;
    }

    return DefWindowProc(hw, msg, wp, lp);
}
コード例 #4
0
ファイル: core_win32.cpp プロジェクト: kkdaemon/proto
LRESULT core_win32::window_proc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam, bool& is_handled)
{
    switch (message)
    {
    case WM_CREATE:
        on_create();
        break;
    case WM_LAMBDA:
        on_lambda(reinterpret_cast<ui_task_type*>(lparam));
        break;
    case WM_SIZE:
        on_size(LOWORD(lparam), HIWORD(lparam), static_cast<int>(wparam));
        break;
    case WM_SETFOCUS:
    case WM_KILLFOCUS:
        on_focus_changed(message == WM_SETFOCUS);
        break;
    case WM_ENTERSIZEMOVE:
    case WM_EXITSIZEMOVE:
        on_enter_exit_sizemove(message == WM_ENTERSIZEMOVE);
        break;
    case WM_GETMINMAXINFO:
        on_get_minmax_info(reinterpret_cast<MINMAXINFO*>(lparam));
        break;
    case WM_DESTROY:
        on_destroy();
        break;
    default:
        is_handled = false;
        break;
    }
    return 0;
}
コード例 #5
0
ファイル: control.hpp プロジェクト: myun2/roast_ex_directx
			LRESULT callback_main(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
			{
				//m_hWnd = hWnd;

				switch( msg )
				{
				case WM_CLOSE:	
					if ( on_close() )
						::DestroyWindow(hWnd);
					return 0;

				case WM_CREATE:	
					return ( on_create((::LPCREATESTRUCT)lParam) ? 0 : -1 );

				case WM_DESTROY:
					on_destroy();
					return 0;

				case WM_MOVE:
					on_move(LOWORD(lParam), HIWORD(lParam));
					return 0;

				case WM_SIZING:
					switch(wParam)
					{
					case WMSZ_LEFT:
						on_sizing(sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_RIGHT:
						on_sizing(sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					case WMSZ_TOP:
						on_sizing(sizing_hold_bit_top, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOM:
						on_sizing(sizing_hold_bit_bottom, (const LPRECT)lParam);
						break;
						
					case WMSZ_TOPLEFT:
						on_sizing(sizing_hold_bit_top | sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_TOPRIGHT:
						on_sizing(sizing_hold_bit_top | sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOMLEFT:
						on_sizing(sizing_hold_bit_bottom | sizing_hold_bit_left, (const LPRECT)lParam);
						break;
					case WMSZ_BOTTOMRIGHT:
						on_sizing(sizing_hold_bit_bottom | sizing_hold_bit_right, (const LPRECT)lParam);
						break;
					}
					return TRUE;
				}

				return ::DefWindowProc( hWnd, msg, wParam, lParam );
			}
コード例 #6
0
ファイル: access_byid.cpp プロジェクト: GreatStone/terark-db
void access_byid::destroy()
{
	std::vector<uintptr_t> used_id;
	get_used_id(&used_id);
	for (uintptr_t i = 0; i != used_id.size(); ++i)
	{
		void* x = (void*)this->get_val(used_id[i]);
		on_destroy(x);
	}
	this->clear();
}
コード例 #7
0
ファイル: access_byid.cpp プロジェクト: RedSunCMX/izenelib
void access_byid<void*>::destroy()
{
	std::vector<uintptr_t> used_id;
	get_used_id(used_id);
	for (long i = 0; i != static_cast<long>(used_id.size()); ++i)
	{
		void* x = (void*)this->get_val(used_id[i]);
		on_destroy(x);
	}
	this->clear();
}
コード例 #8
0
void RepeatedTimerTask::destroy() {
    std::unique_lock<raft_mutex_t> lck(_mutex);
    BRAFT_RETURN_IF(_destroyed);
    _destroyed = true;
    if (!_running) {
        CHECK(_stopped);
        lck.unlock();
        on_destroy();
        return;
    }
    BRAFT_RETURN_IF(_stopped);
    _stopped = true;
    const int rc = bthread_timer_del(_timer);
    if (rc == 0) {
        _running = false;
        lck.unlock();
        on_destroy();
        return;
    }
    CHECK(_running);
}
コード例 #9
0
void NativeEngine::handle_cmd(int32_t cmd){
	switch (cmd) {
		case APP_CMD_INPUT_CHANGED:
			on_input_changed();
			break;
		case APP_CMD_INIT_WINDOW:
			on_init_window();
			break;
		case APP_CMD_TERM_WINDOW:
			on_term_window();
			break;
		case APP_CMD_WINDOW_RESIZED:
			on_window_resized();
			break;
		case APP_CMD_WINDOW_REDRAW_NEEDED:
			on_window_redraw_needed();
			break;
		case APP_CMD_CONTENT_RECT_CHANGED:
			on_content_rect_changed();
			break;
		case APP_CMD_GAINED_FOCUS:
			on_gained_focus();
			break;
		case APP_CMD_LOST_FOCUS:
			on_lost_focus();
			break;
		case APP_CMD_CONFIG_CHANGED:
			on_config_changed();
			break;
		case APP_CMD_LOW_MEMORY:
			on_low_memory();
			break;
		case APP_CMD_START:
			on_start();
			break;
		case APP_CMD_RESUME:
			on_resume();
			break;
		case APP_CMD_SAVE_STATE:
			on_save_state();
			break;
		case APP_CMD_PAUSE:
			on_pause();
			break;
		case APP_CMD_STOP:
			on_stop();
			break;
		case APP_CMD_DESTROY:
			on_destroy();
			break;
	}
}
コード例 #10
0
ファイル: window.hpp プロジェクト: 8l/x11
      virtual void destroy()
	{
	  hide();

 	  if ( m_window )
	    {
	      XDestroyWindow ( m_display, m_window );
	      m_window = 0;
	    }

	  m_event_dispatcher.unregister_window ( this );

	  on_destroy();
	}
コード例 #11
0
ファイル: kn_stream_socket.c プロジェクト: ifzz/distri.lua
int stream_socket_close(handle_t h){
	if(h->type != KN_SOCKET && ((kn_socket*)h)->type != SOCK_STREAM)
		return -1;
	kn_socket *s = (kn_socket*)h;
	if(h->status != SOCKET_CLOSE){
		if(h->inloop){
			h->status = SOCKET_CLOSE;
			//shutdown(h->fd,SHUT_WR);
			//kn_push_destroy(s->e,h);
		}else
			on_destroy(s);				
		return 0;
	}
	return -1;	
}
コード例 #12
0
ファイル: Window.cpp プロジェクト: bugburner/xcsoar
void
Window::reset()
{
#ifdef ENABLE_SDL
  on_destroy();
  canvas.reset();
#else /* !ENABLE_SDL */
  if (hWnd != NULL) {
    ::DestroyWindow(hWnd);

    /* the on_destroy() method must have cleared the variable by
       now */
    assert(prev_wndproc == NULL || hWnd == NULL);

    hWnd = NULL;
  }
#endif /* !ENABLE_SDL */
}
コード例 #13
0
ファイル: access_byid.cpp プロジェクト: RedSunCMX/izenelib
	//! delete all object in list, and clear self
void AccessByNameID<void*>::destroy()
{
	std::vector<uintptr_t> used_id;
	m_byid.get_used_id(used_id);
	std::vector<uintptr_t> bynamep(m_byname.size());
	std::map<std::string, void*>::iterator iter = m_byname.begin();
	for (long i = 0; iter != m_byname.end(); ++iter)
		bynamep[i++] = (uintptr_t)iter->second;
	for (long i = 0; i != static_cast<long>(used_id.size()); ++i)
		used_id[i] = m_byid.get_val(used_id[i]);
	std::sort(used_id.begin(), used_id.end());
	std::sort(bynamep.begin(), bynamep.end());
	long n = std::set_union(used_id.begin(), used_id.end(), bynamep.begin(), bynamep.end(), used_id.begin()) - used_id.begin();
	assert(static_cast<long>(used_id.size()) == n);
	for (long i = 0; i != static_cast<long>(used_id.size()); ++i)
	{
		on_destroy((void*)used_id[i]);
	}
	m_byid.clear();
	m_byname.clear();
}
コード例 #14
0
void RepeatedTimerTask::on_timedout() {
    std::unique_lock<raft_mutex_t> lck(_mutex);
    _invoking = true;
    lck.unlock();
    //   ^^^NOTE: don't invoke run() inside lock to avoid the dead-lock issue
    run();
    lck.lock();
    _invoking = false;
    CHECK(_running);
    if (_stopped) {
        _running = false;
        if (_destroyed) {
            // this may call the destruction,
            // so do this after setting _running to false
            lck.unlock();
            on_destroy();
        }
        return;
    }
    return schedule(lck);
}
コード例 #15
0
ファイル: linkedlist.c プロジェクト: spacefan/LCUI
void LinkedList_ClearEx( LinkedList *list, void(*on_destroy)(void*),
			 int free_node )
{
	LinkedListNode *prev, *node;
	node = list->tail.prev;
	list->head.next = NULL;
	list->tail.prev = NULL;
	list->length = 0;
	while( node && node != &list->head ) {
		prev = node->prev;
		node->prev = NULL;
		node->next = NULL;
		if( node->data && on_destroy ) {
			on_destroy( node->data );
		}
		if( free_node ) {
			free( node );
		}
		node = prev;
	}
}
コード例 #16
0
ファイル: access_byid.cpp プロジェクト: GreatStone/terark-db
//! delete all object in list, and clear self
void AccessByNameID<void*>::destroy()
{
	std::vector<uintptr_t> used_id;
	m_byid.get_used_id(&used_id);
	std::vector<uintptr_t> bynamep(m_byname->size());
	NameMapForAccessByNameID::iterator iter = m_byname->begin();
	for (uintptr_t i = 0; iter != m_byname->end(); ++iter)
		bynamep[i++] = (uintptr_t)iter->second;
	for (uintptr_t i = 0; i != used_id.size(); ++i)
		used_id[i] = m_byid.get_val(used_id[i]);
	std::sort(used_id.begin(), used_id.end());
	std::sort(bynamep.begin(), bynamep.end());
	uintptr_t n = std::set_union(used_id.begin(), used_id.end(),
		bynamep.begin(), bynamep.end(), used_id.begin()) - used_id.begin();
	assert(used_id.size() == n);
	if (used_id.size() != n) {
		THROW_STD(runtime_error,
			"(used_id.size=%zd) != (n=%zd)", used_id.size(), n);
	}
	for (uintptr_t i = 0; i != n; ++i)
		on_destroy((void*)used_id[i]);
	m_byid.clear();
	m_byname->clear();
}
コード例 #17
0
ファイル: access_byid.cpp プロジェクト: GreatStone/terark-db
void AccessByNameID<void*>::remove(uintptr_t id)
{
	void* p = m_byid.get_ptr(id);
	m_byid.free_id(id);
	on_destroy(p);
}
コード例 #18
0
ファイル: Window.cpp プロジェクト: bugburner/xcsoar
LRESULT
Window::on_message(HWND _hWnd, UINT message,
                       WPARAM wParam, LPARAM lParam)
{
  switch (message) {
  case WM_CREATE:
    return on_create() ? 0 : -1;
    break;

  case WM_DESTROY:
    if (on_destroy()) return 0;
    break;

  case WM_CLOSE:
    if (on_close())
      /* true returned: message was handled */
      return 0;
    break;

  case WM_SIZE:
    if (on_resize(LOWORD(lParam), HIWORD(lParam))) return 0;
    break;

  case WM_MOUSEMOVE:
    if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam))
      return 0;
    break;

  case WM_LBUTTONDOWN:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONUP:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONDBLCLK:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

#ifdef WM_MOUSEWHEEL
  case WM_MOUSEWHEEL:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_mouse_wheel(GET_WHEEL_DELTA_WPARAM(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;
#endif

  case WM_KEYDOWN:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_key_down(wParam)) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_KEYUP:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_key_up(wParam)) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_COMMAND:
    XCSoarInterface::InterfaceTimeoutReset();
    if (on_command(LOWORD(wParam), HIWORD(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_SETFOCUS:
    if (on_setfocus())
      return 0;
    break;

  case WM_KILLFOCUS:
    if (on_killfocus())
      return 0;
    break;

  case WM_TIMER:
    if (on_timer(wParam))
      return 0;
    break;
  }

  if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER))
    return 0;

  return on_unhandled_message(_hWnd, message, wParam, lParam);
}
コード例 #19
0
LRESULT
Window::on_message(HWND _hWnd, UINT message,
                       WPARAM wParam, LPARAM lParam)
{
  if (IsEmbedded() && !IsAltair()) {
    /* some older iPaqs such as the H3900 send only WM_KEYUP for
       VK_APP*, but never VK_KEYDOWN; the hx4700 has an additional set
       of undocumented key codes (0xca..0xcd) for the APP keys, but
       sends WM_KEYUP/VK_APP* additionally; the following rules
       hopefully catch all of these obscurities */
    if (message == WM_KEYUP && wParam >= 0x80)
      /* convert to WM_KEYDOWN to make all handlers catch it */
      message = WM_KEYDOWN;
    else if (message == WM_KEYDOWN && wParam >= 0x80)
      /* ignore the real WM_KEYDOWN, just in case it really happens */
      return 0;
  }

  switch (message) {
  case WM_CREATE:
    on_create();
    return 0;

  case WM_DESTROY:
    on_destroy();
    return 0;

  case WM_CLOSE:
    if (on_close())
      /* true returned: message was handled */
      return 0;
    break;

  case WM_SIZE:
    on_resize(LOWORD(lParam), HIWORD(lParam));
    return 0;

  case WM_MOUSEMOVE:
    if (on_mouse_move(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam))
      return 0;
    break;

  case WM_LBUTTONDOWN:
    if (on_mouse_down(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONUP:
    if (on_mouse_up(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_LBUTTONDBLCLK:
    if (!double_clicks)
      /* instead of disabling CS_DBLCLKS (which would affect all
         instances of a window class), we just translate
         WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for
         built-in window class such as BUTTON */
      return on_message(_hWnd, WM_LBUTTONDOWN, wParam, lParam);

    if (on_mouse_double(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }

    break;

#ifdef WM_MOUSEWHEEL
  case WM_MOUSEWHEEL:
    if (on_mouse_wheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam),
                       GET_WHEEL_DELTA_WPARAM(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;
#endif

  case WM_KEYDOWN:
    if (on_key_down(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_KEYUP:
    if (on_key_up(::TranscodeKey(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_COMMAND:
    if (on_command(LOWORD(wParam), HIWORD(wParam))) {
      /* true returned: message was handled */
      ResetDisplayTimeOut();
      return 0;
    }
    break;

  case WM_CANCELMODE:
    if (on_cancel_mode())
      return 0;
    break;

  case WM_SETFOCUS:
    on_setfocus();
    return 0;

  case WM_KILLFOCUS:
    on_killfocus();
    return 0;

  case WM_TIMER:
    if (on_timer(*(WindowTimer *)wParam))
      return 0;
    break;

  case WM_PAINT:
    if (custom_painting) {
      PaintCanvas canvas(*this);
      on_paint(canvas, canvas.get_dirty());
      return 0;
    }
    break;

  case WM_GETDLGCODE:
    if (on_key_check(wParam))
      return DLGC_WANTMESSAGE;
    break;
  }

  if (message >= WM_USER && message <= 0x7FFF && on_user(message - WM_USER))
    return 0;

  return on_unhandled_message(_hWnd, message, wParam, lParam);
}
コード例 #20
0
afx_msg void kWindow::OnDestroy()
{
 on_destroy();
 CWnd::OnDestroy();
}