30 prefix_ senf::scheduler::detail::FdDispatcher::~FdDispatcher()
32 for (FdSet::iterator i (fds_.begin()); i != fds_.end(); ++i) {
33 detail::FdManager::instance().remove(i->fd_);
34 detail::FIFORunner::instance().dequeue(&(*i));
38 prefix_ bool senf::scheduler::detail::FdDispatcher::add(FdEvent & event)
40 std::pair<FdSet::iterator,FdSet::iterator> range (fds_.equal_range(event));
42 for (FdSet::iterator i (range.first); i != range.second; ++i)
44 if (event.events_ & events)
45 throw FdEvent::DuplicateEventRegistrationException() <<
"vinfo: " <<
event.v_info();
47 if (! detail::FdManager::instance().
set(event.fd_, events | event.events_, &event))
50 detail::FIFORunner::instance().enqueue(&event);
51 fds_.insert(range.first, event);
56 prefix_ void senf::scheduler::detail::FdDispatcher::remove(FdEvent & event)
58 fds_.erase(FdSet::s_iterator_to(event));
59 detail::FIFORunner::instance().dequeue(&event);
61 std::pair<FdSet::iterator,FdSet::iterator> range (fds_.equal_range(event));
62 if (range.first == range.second)
63 detail::FdManager::instance().remove(event.fd_);
66 for (FdSet::iterator i (range.first); i != range.second; ++i)
68 detail::FdManager::instance().set(event.fd_, events, &(*range.first));
75 prefix_ void senf::scheduler::detail::FileDispatcher::add(FdEvent & event)
77 std::pair<FdSet::iterator,FdSet::iterator> range (fds_.equal_range(event));
79 for (FdSet::iterator i (range.first); i != range.second; ++i)
81 if (event.events_ & events)
82 throw FdEvent::DuplicateEventRegistrationException() <<
"vinfo: " <<
event.v_info();
84 detail::FIFORunner::instance().enqueue(&event);
85 fds_.insert(range.first, event);
87 detail::FdManager::instance().timeout(0);
90 prefix_ senf::scheduler::detail::FileDispatcher::FileDispatcher()
91 : managerTimeout_ (scheduler::detail::FdManager::instance().timeout())
94 prefix_ senf::scheduler::detail::FileDispatcher::~FileDispatcher()
96 detail::FdManager::instance().timeout(-1);
97 for (FdSet::iterator i (fds_.begin()); i != fds_.end(); ++i)
98 detail::FIFORunner::instance().dequeue(&(*i));
101 prefix_ void senf::scheduler::detail::FileDispatcher::prepareRun()
103 for (FdSet::iterator i (fds_.begin()); i != fds_.end(); ++i) {
104 i->signaledEvents_ = i->events_;
109 prefix_ void senf::scheduler::detail::FileDispatcher::remove(FdEvent & event)
111 fds_.erase(FdSet::s_iterator_to(event));
112 detail::FIFORunner::instance().dequeue(&event);
114 detail::FdManager::instance().timeout(managerTimeout_);
124 detail::FdDispatcher::instance().remove(*
this);
126 detail::FileDispatcher::instance().remove(*
this);
132 if (!
enabled() && events_ && fd_ != -1) {
133 if (pollable_ && detail::FdDispatcher::instance().add(*
this))
135 detail::FileDispatcher::instance().add(*
this);
152 detail::FdDispatcher::FdSet::iterator i (detail::FdDispatcher::FdSet::s_iterator_to(*
this));
153 detail::FdDispatcher::FdSet::iterator
const i_end (detail::FdDispatcher::instance().fds_.end());
155 for (; i != i_end && fd_ == i->fd_; ++i) {
156 i->signaledEvents_ = events & (
EV_ERR |
EV_HUP | i->events_);
157 if (i->events_ & events || all)
162 prefix_ void senf::scheduler::FdEvent::v_run()
164 cb_(signaledEvents_);
167 prefix_ char const * senf::scheduler::FdEvent::v_type()
173 prefix_ std::string senf::scheduler::FdEvent::v_info()
176 std::stringstream ss;
180 ss <<
" (NOT pollable)";
bool enabled() const
true, if event is enabled, false otherwise
void disable()
Disable event.
FdDispatcher public header.
void enable()
Enable event.
remote end closed connection
OOB data available for read.
int events()
Current event mask.