 Chromium Code Reviews
 Chromium Code Reviews Issue 23498015:
  [NaCl SDK] Support non blocking TCP/UDP  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 23498015:
  [NaCl SDK] Support non blocking TCP/UDP  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: native_client_sdk/src/libraries/nacl_io/event_emitter.h | 
| diff --git a/native_client_sdk/src/libraries/nacl_io/event_emitter.h b/native_client_sdk/src/libraries/nacl_io/event_emitter.h | 
| index 96670b6c3683cf03bee2d2de664126cc77738c0a..9f0924035adbcb58b760e7a51988d62a72bfa0e6 100644 | 
| --- a/native_client_sdk/src/libraries/nacl_io/event_emitter.h | 
| +++ b/native_client_sdk/src/libraries/nacl_io/event_emitter.h | 
| @@ -22,32 +22,12 @@ namespace nacl_io { | 
| class EventEmitter; | 
| class EventListener; | 
| -// A ref counted object (non POD derived from RefObject) for storing the | 
| -// state of a single signal request. Requests are unique to any | 
| -// FD/EventListener pair. | 
| -struct EventInfo : public sdk_util::RefObject { | 
| - // User provied data to be returned on EventListener::Wait | 
| - uint64_t user_data; | 
| - | 
| - // Bitfield of POLL events currently signaled. | 
| - uint32_t events; | 
| - | 
| - // Bitfield of POLL events of interest. | 
| - uint32_t filter; | 
| - | 
| - // We do not use a ScopedRef to prevent circular references. | 
| - EventEmitter* emitter; | 
| - EventListener* listener; | 
| - uint32_t id; | 
| -}; | 
| - | 
| -typedef sdk_util::ScopedRef<EventInfo> ScopedEventInfo; | 
| -// Provide comparison for std::map and std::set | 
| -bool operator<(const ScopedEventInfo& src_a, const ScopedEventInfo& src_b); | 
| +typedef sdk_util::ScopedRef<EventEmitter> ScopedEventEmitter; | 
| +typedef std::map<EventListener*, uint32_t> EventListenerMap_t; | 
| -typedef std::map<int, ScopedEventInfo> EventInfoMap_t; | 
| -typedef std::set<ScopedEventInfo> EventInfoSet_t; | 
| +bool operator<(const ScopedEventEmitter& src_a, | 
| + const ScopedEventEmitter& src_b); | 
| // EventEmitter | 
| // | 
| @@ -56,47 +36,30 @@ typedef std::set<ScopedEventInfo> EventInfoSet_t; | 
| // whenever thier state is changed. | 
| // | 
| // See "Kernel Events" in event_listener.h for additional information. | 
| + | 
| class EventEmitter : public sdk_util::RefObject { | 
| - protected: | 
| - // Called automatically prior to delete to inform the EventListeners that | 
| - // this EventEmitter is abandoning an associated EventInfo. | 
| - virtual void Destroy(); | 
| + public: | 
| + // Returns the current state of the emitter as POLL events bitfield. | 
| + virtual uint32_t GetEventStatus() = 0; | 
| + sdk_util::SimpleLock& GetLock() { return emitter_lock_; } | 
| - private: | 
| // Register or unregister an EventInfo. The lock of the EventListener | 
| // associated with this EventInfo must be held prior to calling these | 
| // functions. These functions are private to ensure they are called by the | 
| // EventListener. | 
| - void RegisterEventInfo(const ScopedEventInfo& info); | 
| - void UnregisterEventInfo(const ScopedEventInfo& info); | 
| + void RegisterListener(EventListener* listener, uint32_t events); | 
| + void UnregisterListener(EventListener* listener); | 
| - public: | 
| - // Returns the current state of the emitter as POLL events bitfield. | 
| - virtual uint32_t GetEventStatus() = 0; | 
| - | 
| - // Returns the type of the emitter (compatible with st_mode in stat) | 
| - virtual int GetType() = 0; | 
| + // Event lock must be held when this function is called. | 
| + void RaiseEvents_Locked(uint32_t events); | 
| + void RegisterListener_Locked(EventListener* listener, uint32_t events); | 
| + void UnregisterListener_Locked(EventListener* listener); | 
| protected: | 
| 
binji
2013/09/12 01:47:57
private?
 
noelallen1
2013/09/12 23:19:03
Done.
 | 
| - // Called by the thread causing the Event. | 
| - void RaiseEvent(uint32_t events); | 
| - | 
| - // Provided to allow one EventEmitter to register the same EventInfo with | 
| - // a child EventEmitter so that they can both signal the EventListener. | 
| - // Called after registering locally, but while lock is still held. | 
| - virtual void ChainRegisterEventInfo(const ScopedEventInfo& event); | 
| - | 
| - // Called before unregistering locally, but while lock is still held. | 
| - virtual void ChainUnregisterEventInfo(const ScopedEventInfo& event); | 
| - | 
| -private: | 
| sdk_util::SimpleLock emitter_lock_; | 
| - EventInfoSet_t events_; | 
| - friend class EventListener; | 
| + EventListenerMap_t listeners_; | 
| }; | 
| -typedef sdk_util::ScopedRef<EventEmitter> ScopedEventEmitter; | 
| - | 
| } // namespace nacl_io |