Searched defs:Dispatcher (Results 1 - 7 of 7) sorted by relevance

/external/chromium/base/
H A Dmessage_pump_glib.h38 // Dispatcher is used during a nested invocation of Run to dispatch events.
39 // If Run is invoked with a non-NULL Dispatcher, MessageLoop does not
41 // passed to Dispatcher's Dispatch method for dispatch. It is up to the
42 // Dispatcher to dispatch, or not, the event.
46 class Dispatcher { class in class:base::MessagePumpForUI
48 virtual ~Dispatcher() {}
58 virtual void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher);
94 Dispatcher* GetDispatcher();
H A Dmessage_pump_win.h45 // Dispatcher is used during a nested invocation of Run to dispatch events.
46 // If Run is invoked with a non-NULL Dispatcher, MessageLoop does not
48 // passed to Dispatcher's Dispatch method for dispatch. It is up to the
49 // Dispatcher to dispatch, or not, the event.
53 class Dispatcher { class in class:base::MessagePumpWin
55 virtual ~Dispatcher() {}
77 void RunWithDispatcher(Delegate* delegate, Dispatcher* dispatcher);
86 Dispatcher* dispatcher;
H A Dmessage_loop.h21 // We need this to declare base::MessagePumpWin::Dispatcher, which we should
72 typedef base::MessagePumpWin::Dispatcher Dispatcher; typedef in class:MessageLoop
76 typedef base::MessagePumpGlibXDispatcher Dispatcher;
78 typedef base::MessagePumpForUI::Dispatcher Dispatcher;
344 Dispatcher* dispatcher;
549 void Run(Dispatcher* dispatcher);
/external/chromium/third_party/libjingle/source/talk/base/
H A Dphysicalsocketserver.h44 // Event constants for the Dispatcher class.
58 class Dispatcher { class in namespace:talk_base
60 virtual ~Dispatcher() {}
91 void Add(Dispatcher* dispatcher);
92 void Remove(Dispatcher* dispatcher);
111 typedef std::vector<Dispatcher*> DispatcherList;
H A Dphysicalsocketserver.cc523 class EventDispatcher : public Dispatcher {
698 class PosixSignalDispatcher : public Dispatcher {
771 class SocketDispatcher : public Dispatcher, public PhysicalSocket {
879 class FileDispatcher: public Dispatcher, public AsyncFile {
961 class EventDispatcher : public Dispatcher {
1009 class SocketDispatcher : public Dispatcher, public PhysicalSocket {
1202 void PhysicalSocketServer::Add(Dispatcher *pdispatcher) {
1213 void PhysicalSocketServer::Remove(Dispatcher *pdispatcher) {
1268 Dispatcher *pdispatcher = dispatchers_[i];
1307 Dispatcher *pdispatche
598 ASSERT(signum < ARRAY_SIZE(received_signal_)); if (signum < ARRAY_SIZE(received_signal_)) { return received_signal_[signum]; } else { return false; } } void ClearSignal(int signum) { ASSERT(signum < ARRAY_SIZE(received_signal_)); if (signum < ARRAY_SIZE(received_signal_)) { received_signal_[signum] = false; } } int GetDescriptor() const { return afd_[0]; } void OnPosixSignalReceived(int signum) { if (signum >= ARRAY_SIZE(received_signal_)) { return; } received_signal_[signum] = true; const uint8 b[1] = { 0 }; if (-1 == write(afd_[1], b, sizeof(b))) { return; } } private: PosixSignalHandler() { if (pipe(afd_) < 0) { LOG_ERR(LS_ERROR) << Ó; return; } if (fcntl(afd_[0], F_SETFL, O_NONBLOCK) < 0) { LOG_ERR(LS_WARNING) << Ó; } if (fcntl(afd_[1], F_SETFL, O_NONBLOCK) < 0) { LOG_ERR(LS_WARNING) << Ó; } memset(const_cast<void *>(static_cast<volatile void *>(received_signal_)), 0, sizeof(received_signal_)); } ~PosixSignalHandler() { int fd1 = afd_[0]; int fd2 = afd_[1]; afd_[0] = -1; afd_[1] = -1; close(fd1); close(fd2); } static PosixSignalHandler instance_; int afd_[2]; volatile uint8 received_signal_[kNumPosixSignals]; }; PosixSignalHandler PosixSignalHandler::instance_; class PosixSignalDispatcher : public Dispatcher { public: PosixSignalDispatcher(PhysicalSocketServer *owner) : owner_(owner) { owner_->Add(this); } virtual ~PosixSignalDispatcher() { owner_->Remove(this); } virtual uint32 GetRequestedEvents() { return DE_READ; } virtual void OnPreEvent(uint32 ff) { uint8 b[16]; ssize_t ret = read(GetDescriptor(), b, sizeof(b)); if (ret < 0) { LOG_ERR(LS_WARNING) << Ó; } else if (ret == 0) { LOG(LS_WARNING) << Ó; } } virtual void OnEvent(uint32 ff, int err) { for (int signum = 0; signum < PosixSignalHandler::kNumPosixSignals; ++signum) { if (PosixSignalHandler::Instance()->IsSignalSet(signum)) { PosixSignalHandler::Instance()->ClearSignal(signum); HandlerMap::iterator i = handlers_.find(signum); if (i == handlers_.end()) { LOG(LS_INFO) << Ó << signum; } else { (*i->second)(signum); } } } } virtual int GetDescriptor() { return PosixSignalHandler::Instance()->GetDescriptor(); } virtual bool IsDescriptorClosed() { return false; } void SetHandler(int signum, void (*handler)(int)) { handlers_[signum] = handler; } void ClearHandler(int signum) { handlers_.erase(signum); } bool HasHandlers() { return !handlers_.empty(); } private: typedef std::map<int, void (*)(int)> HandlerMap; HandlerMap handlers_; PhysicalSocketServer *owner_; }; class SocketDispatcher : public Dispatcher, public PhysicalSocket { public: explicit SocketDispatcher(PhysicalSocketServer *ss) : PhysicalSocket(ss) { } SocketDispatcher(SOCKET s, PhysicalSocketServer *ss) : PhysicalSocket(ss, s) { } virtual ~SocketDispatcher() { Close(); } bool Initialize() { ss_->Add(this); fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK); return true; } virtual bool Create(int type) { if (!PhysicalSocket::Create(type)) return false; return Initialize(); } virtual int GetDescriptor() { return s_; } virtual bool IsDescriptorClosed() { char ch; ssize_t res = ::recv(s_, &ch, 1, MSG_PEEK); if (res > 0) { return false; } else if (res == 0) { return true; } else { switch (errno) { case EBADF: case ECONNRESET: return true; default: LOG_ERR(LS_WARNING) << Ó; return false; } } } virtual uint32 GetRequestedEvents() { return enabled_events_; } virtual void OnPreEvent(uint32 ff) { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; if ((ff & DE_CLOSE) != 0) state_ = CS_CLOSED; } virtual void OnEvent(uint32 ff, int err) { if ((ff & DE_READ) != 0) { enabled_events_ &= ~DE_READ; SignalReadEvent(this); } if ((ff & DE_WRITE) != 0) { enabled_events_ &= ~DE_WRITE; SignalWriteEvent(this); } if ((ff & DE_CONNECT) != 0) { enabled_events_ &= ~DE_CONNECT; SignalConnectEvent(this); } if ((ff & DE_ACCEPT) != 0) { enabled_events_ &= ~DE_ACCEPT; SignalReadEvent(this); } if ((ff & DE_CLOSE) != 0) { enabled_events_ = 0; SignalCloseEvent(this, err); } } virtual int Close() { if (s_ == INVALID_SOCKET) return 0; ss_->Remove(this); return PhysicalSocket::Close(); } }; class FileDispatcher: public Dispatcher, public AsyncFile { public: FileDispatcher(int fd, PhysicalSocketServer *ss) : ss_(ss), fd_(fd) { set_readable(true); ss_->Add(this); fcntl(fd_, F_SETFL, fcntl(fd_, F_GETFL, 0) | O_NONBLOCK); } virtual ~FileDispatcher() { ss_->Remove(this); } SocketServer* socketserver() { return ss_; } virtual int GetDescriptor() { return fd_; } virtual bool IsDescriptorClosed() { return false; } virtual uint32 GetRequestedEvents() { return flags_; } virtual void OnPreEvent(uint32 ff) { } virtual void OnEvent(uint32 ff, int err) { if ((ff & DE_READ) != 0) SignalReadEvent(this); if ((ff & DE_WRITE) != 0) SignalWriteEvent(this); if ((ff & DE_CLOSE) != 0) SignalCloseEvent(this, err); } virtual bool readable() { return (flags_ & DE_READ) != 0; } virtual void set_readable(bool value) { flags_ = value ? (flags_ | DE_READ) : (flags_ & ~DE_READ); } virtual bool writable() { return (flags_ & DE_WRITE) != 0; } virtual void set_writable(bool value) { flags_ = value ? (flags_ | DE_WRITE) : (flags_ & ~DE_WRITE); } private: PhysicalSocketServer* ss_; int fd_; int flags_; }; AsyncFile* PhysicalSocketServer::CreateFile(int fd) { return new FileDispatcher(fd, this); } static uint32 FlagsToEvents(uint32 events) { uint32 ffFD = FD_CLOSE; if (events & DE_READ) ffFD |= FD_READ; if (events & DE_WRITE) ffFD |= FD_WRITE; if (events & DE_CONNECT) ffFD |= FD_CONNECT; if (events & DE_ACCEPT) ffFD |= FD_ACCEPT; return ffFD; } class EventDispatcher : public Dispatcher { public: EventDispatcher(PhysicalSocketServer *ss) : ss_(ss) { hev_ = WSACreateEvent(); if (hev_) { ss_->Add(this); } } ~EventDispatcher() { if (hev_ != NULL) { ss_->Remove(this); WSACloseEvent(hev_); hev_ = NULL; } } virtual void Signal() { if (hev_ != NULL) WSASetEvent(hev_); } virtual uint32 GetRequestedEvents() { return 0; } virtual void OnPreEvent(uint32 ff) { WSAResetEvent(hev_); } virtual void OnEvent(uint32 ff, int err) { } virtual WSAEVENT GetWSAEvent() { return hev_; } virtual SOCKET GetSocket() { return INVALID_SOCKET; } virtual bool CheckSignalClose() { return false; } private: PhysicalSocketServer* ss_; WSAEVENT hev_; }; class SocketDispatcher : public Dispatcher, public PhysicalSocket { public: static int next_id_; int id_; bool signal_close_; int signal_err_; SocketDispatcher(PhysicalSocketServer* ss) : PhysicalSocket(ss), id_(0), signal_close_(false) { } SocketDispatcher(SOCKET s, PhysicalSocketServer* ss) : PhysicalSocket(ss, s), id_(0), signal_close_(false) { } virtual ~SocketDispatcher() { Close(); } bool Initialize() { ASSERT(s_ != INVALID_SOCKET); u_long argp = 1; ioctlsocket(s_, FIONBIO, &argp); ss_->Add(this); return true; } virtual bool Create(int type) { if (!PhysicalSocket::Create(type)) return false; if (!Initialize()) return false; do { id_ = ++next_id_; } while (id_ == 0); return true; } virtual int Close() { if (s_ == INVALID_SOCKET) return 0; id_ = 0; signal_close_ = false; ss_->Remove(this); return PhysicalSocket::Close(); } virtual uint32 GetRequestedEvents() { return enabled_events_; } virtual void OnPreEvent(uint32 ff) { if ((ff & DE_CONNECT) != 0) state_ = CS_CONNECTED; } virtual void OnEvent(uint32 ff, int err) { int cache_id = id_; if ((ff & DE_READ) != 0) { enabled_events_ &= ~DE_READ; SignalReadEvent(this); } if (((ff & DE_WRITE) != 0) && (id_ == cache_id)) { enabled_events_ &= ~DE_WRITE; SignalWriteEvent(this); } if (((ff & DE_CONNECT) != 0) && (id_ == cache_id)) { if (ff != DE_CONNECT) LOG(LS_VERBOSE) << Ó << ff; enabled_events_ &= ~DE_CONNECT; dbg_addr_ = Ó; dbg_addr_.append(GetRemoteAddress().ToString()); SignalConnectEvent(this); } if (((ff & DE_ACCEPT) != 0) && (id_ == cache_id)) { enabled_events_ &= ~DE_ACCEPT; SignalReadEvent(this); } if (((ff & DE_CLOSE) != 0) && (id_ == cache_id)) { signal_close_ = true; signal_err_ = err; } } virtual WSAEVENT GetWSAEvent() { return WSA_INVALID_EVENT; } virtual SOCKET GetSocket() { return s_; } virtual bool CheckSignalClose() { if (!signal_close_) return false; char ch; if (recv(s_, &ch, 1, MSG_PEEK) > 0) return false; state_ = CS_CLOSED; signal_close_ = false; SignalCloseEvent(this, signal_err_); return true; } }; int SocketDispatcher::next_id_ = 0; class Signaler : public EventDispatcher { public: Signaler(PhysicalSocketServer* ss, bool* pf) : EventDispatcher(ss), pf_(pf) { } virtual ~Signaler() { } void OnEvent(uint32 ff, int err) { if (pf_) *pf_ = false; } private: bool *pf_; }; PhysicalSocketServer::PhysicalSocketServer() : fWait_(false), last_tick_tracked_(0), last_tick_dispatch_count_(0) { signal_wakeup_ = new Signaler(this, &fWait_); socket_ev_ = WSACreateEvent(); } PhysicalSocketServer::~PhysicalSocketServer() { WSACloseEvent(socket_ev_); signal_dispatcher_.reset(); delete signal_wakeup_; ASSERT(dispatchers_.empty()); } void PhysicalSocketServer::WakeUp() { signal_wakeup_->Signal(); } Socket* PhysicalSocketServer::CreateSocket(int type) { PhysicalSocket* socket = new PhysicalSocket(this); if (socket->Create(type)) { return socket; } else { delete socket; return 0; } } AsyncSocket* PhysicalSocketServer::CreateAsyncSocket(int type) { SocketDispatcher* dispatcher = new SocketDispatcher(this); if (dispatcher->Create(type)) { return dispatcher; } else { delete dispatcher; return 0; } } AsyncSocket* PhysicalSocketServer::WrapSocket(SOCKET s) { SocketDispatcher* dispatcher = new SocketDispatcher(s, this); if (dispatcher->Initialize()) { return dispatcher; } else { delete dispatcher; return 0; } } void PhysicalSocketServer::Add(Dispatcher *pdispatcher) { CritScope cs(&crit_); DispatcherList::iterator pos = std::find(dispatchers_.begin(), dispatchers_.end(), pdispatcher); if (pos != dispatchers_.end()) return; dispatchers_.push_back(pdispatcher); } void PhysicalSocketServer::Remove(Dispatcher *pdispatcher) { CritScope cs(&crit_); DispatcherList::iterator pos = std::find(dispatchers_.begin(), dispatchers_.end(), pdispatcher); ASSERT(pos != dispatchers_.end()); size_t index = pos - dispatchers_.begin(); dispatchers_.erase(pos); for (IteratorList::iterator it = iterators_.begin(); it != iterators_.end(); ++it) { if (index < **it) { --**it; } } } bool PhysicalSocketServer::Wait(int cmsWait, bool process_io) { struct timeval *ptvWait = NULL; struct timeval tvWait; struct timeval tvStop; if (cmsWait != kForever) { tvWait.tv_sec = cmsWait / 1000; tvWait.tv_usec = (cmsWait % 1000) * 1000; ptvWait = &tvWait; gettimeofday(&tvStop, NULL); tvStop.tv_sec += tvWait.tv_sec; tvStop.tv_usec += tvWait.tv_usec; if (tvStop.tv_usec >= 1000000) { tvStop.tv_usec -= 1000000; tvStop.tv_sec += 1; } } fd_set fdsRead; FD_ZERO(&fdsRead); fd_set fdsWrite; FD_ZERO(&fdsWrite); fWait_ = true; while (fWait_) { int fdmax = -1; { CritScope cr(&crit_); for (size_t i = 0; i < dispatchers_.size(); ++i) { Dispatcher *pdispatcher = dispatchers_[i]; ASSERT(pdispatcher); if (!process_io && (pdispatcher != signal_wakeup_)) continue; int fd = pdispatcher->GetDescriptor(); if (fd > fdmax) fdmax = fd; uint32 ff = pdispatcher->GetRequestedEvents(); if (ff & (DE_READ | DE_ACCEPT)) FD_SET(fd, &fdsRead); if (ff & (DE_WRITE | DE_CONNECT)) FD_SET(fd, &fdsWrite); } } int n = select(fdmax + 1, &fdsRead, &fdsWrite, NULL, ptvWait); if (n < 0) { if (errno != EINTR) { LOG_E(LS_ERROR, EN, errno) << Ó; return false; } } else if (n == 0) { return true; } else { CritScope cr(&crit_); for (size_t i = 0; i < dispatchers_.size(); ++i) { Dispatcher *pdispatcher = dispatchers_[i]; int fd = pdispatcher->GetDescriptor(); uint32 ff = 0; int errcode = 0; if (FD_ISSET(fd, &fdsRead) || FD_ISSET(fd, &fdsWrite)) { socklen_t len = sizeof(errcode); ::getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &len); } if (FD_ISSET(fd, &fdsRead)) { FD_CLR(fd, &fdsRead); if (pdispatcher->GetRequestedEvents() & DE_ACCEPT) { ff |= DE_ACCEPT; } else if (errcode || pdispatcher->IsDescriptorClosed()) { ff |= DE_CLOSE; } else { ff |= DE_READ; } } if (FD_ISSET(fd, &fdsWrite)) { FD_CLR(fd, &fdsWrite); if (pdispatcher->GetRequestedEvents() & DE_CONNECT) { if (!errcode) { ff |= DE_CONNECT; } else { ff |= DE_CLOSE; } } else { ff |= DE_WRITE; } } if (ff != 0) { pdispatcher->OnPreEvent(ff); pdispatcher->OnEvent(ff, errcode); } } } if (cmsWait != kForever) { ptvWait->tv_sec = 0; ptvWait->tv_usec = 0; struct timeval tvT; gettimeofday(&tvT, NULL); if ((tvStop.tv_sec > tvT.tv_sec) || ((tvStop.tv_sec == tvT.tv_sec) && (tvStop.tv_usec > tvT.tv_usec) argument
[all...]
/external/eclipse-basebuilder/basebuilder-3.6.2/org.eclipse.releng.basebuilder/plugins/
H A Dorg.mortbay.jetty.server_6.1.23.v201004211559.jarMETA-INF/MANIFEST.MF META-INF/ECLIPSEF.SF META-INF/ECLIPSEF.RSA META ...
/external/jdiff/
H A Dxerces.jarMETA-INF/ META-INF/MANIFEST.MF META-INF/services/ org/ org/apache/ org/apache/html/ ...

Completed in 243 milliseconds