bool VPoll::init() { if (!notifier_->ready()) { if (!notifier_->init()) { return false; } IOCallback cb([this](KMEvent ev, void*, size_t) { notifier_->onEvent(ev); }); registerFd(notifier_->getReadFD(), KUMA_EV_READ | KUMA_EV_ERROR, std::move(cb)); } return true; }
bool KQueue::init() { kqueue_fd_ = ::kqueue(); if(INVALID_FD == kqueue_fd_) { return false; } if (!notifier_->ready()) { if(!notifier_->init()) { return false; } IOCallback cb ([this](uint32_t ev) { notifier_->onEvent(ev); }); registerFd(notifier_->getReadFD(), KUMA_EV_READ|KUMA_EV_ERROR, std::move(cb)); } return true; }
void SocketReactor::addEventHandler(const Socket& socket, const Poco::AbstractObserver& observer) { NotifierPtr pNotifier; { FastMutex::ScopedLock lock(_mutex); EventHandlerMap::iterator it = _handlers.find(socket); if (it == _handlers.end()) { pNotifier = new SocketNotifier(socket); _handlers[socket] = pNotifier; } else pNotifier = it->second; } pNotifier->addObserver(this, observer); }
void SocketReactor::removeEventHandler(const Socket& socket, const Poco::AbstractObserver& observer) { NotifierPtr pNotifier; { FastMutex::ScopedLock lock(_mutex); EventHandlerMap::iterator it = _handlers.find(socket); if (it != _handlers.end()) { pNotifier = it->second; if (pNotifier->countObservers() == 1) { _handlers.erase(it); } } } if (pNotifier) { pNotifier->removeObserver(this, observer); } }
void SocketReactor::dispatch(NotifierPtr& pNotifier, SocketNotification* pNotification) { try { pNotifier->dispatch(pNotification); } catch (Exception& exc) { ErrorHandler::handle(exc); } catch (std::exception& exc) { ErrorHandler::handle(exc); } catch (...) { ErrorHandler::handle(); } }
void ICSSW::__clearHandleUnsafe(NotifierPtr& p) { p.__clearHandleUnsafe(); }
void ICSSW::__decRefUnsafe(const NotifierPtr& p) { p->__decRefUnsafe(); }
bool ICSSW::__usesClasses(const NotifierPtr& p) { return p->__usesClasses(); }
void ICSSW::__addObject(const NotifierPtr& p, ::IceInternal::GCCountMap& c) { p->__addObject(c); }
void KQueue::notify() { notifier_->notify(); }
void VPoll::notify() { notifier_->notify(); }