void OpDbUtils::ReportCondition(OP_STATUS status) { if (GetMessageHandler() == NULL) return; if (status == OpStatus::ERR_NO_MEMORY) { #ifdef SQLITE_SUPPORT sqlite3_release_memory(50 << 20); #endif //SQLITE_SUPPORT GetMessageHandler()->PostOOMCondition(TRUE); } else if (status == OpStatus::ERR_SOFT_NO_MEMORY) { #ifdef SQLITE_SUPPORT sqlite3_release_memory(10 << 20); #endif //SQLITE_SUPPORT GetMessageHandler()->PostOOMCondition(FALSE); } else if (status == OpStatus::ERR_NO_DISK) { GetMessageHandler()->PostOODCondition(); } else OpStatus::Ignore(status); }
LRESULT CALLBACK winapiwrapper::WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { tyMessageIterator itHandler = GetMessageHandler(Msg); //получаем итератор контейнера мэп с указателем на нужный метод, обрабатывающий событие if(itHandler != m_MsgHandlers.end()) // если он найден (итератор не равен нулевому в списке) { tyMessageHandler handl = itHandler->second; //получаем указатель на этот метод return (this->*handl)(hWnd, wParam, lParam); //вызываем его с полученными от винды параметрами } else return DefWindowProc(hWnd, Msg, wParam, lParam); //если не найден, то обрабатываем виндой }
bool IAppInterface::ListenMessage() { //创建sock pair int32_t fd[2]; int32_t ret = socketpair(AF_UNIX, SOCK_STREAM, 0, fd); if(ret == -1) { LOG_ERROR(logger, "create socket pair failed. errno="<<errno<<"("<<strerror(errno)<<")"); return false; } if(Socket::SetNoBlock(fd[0]) == false) { LOG_ERROR(logger, "set message fd noblock failed. fd="<<fd[0]); close(fd[0]); close(fd[1]); } LOG_DEBUG(logger, "set message fd noblock succ. fd="<<fd[0]); IEventServer *event_server = GetEventServer(); IEventHandler *event_handler = GetMessageHandler(); assert(event_server != NULL); assert(event_handler != NULL); if(!event_server->SetEvent(fd[0], ET_PER_RD, event_handler, -1)) { LOG_ERROR(logger, "add persist read event to event_server failed. fd="<<fd[0]); close(fd[0]); close(fd[1]); return false; } LOG_DEBUG(logger, "add message listen to event server succ. read_fd="<<fd[0]<<" write_fd="<<fd[1]); m_RecvFd = fd[0]; m_WriteFd = fd[1]; return true; }