21 #ifndef COMMON_IO_KQUEUEPOLLER_H_ 22 #define COMMON_IO_KQUEUEPOLLER_H_ 25 #include <ola/Clock.h> 28 #include <sys/event.h> 36 #include "common/io/PollerInterface.h" 37 #include "common/io/TimeoutManager.h" 64 bool delete_on_close);
71 const TimeStamp *WakeUpTime()
const {
return &m_wake_up_time; }
77 enum { CHANGE_SET_SIZE = 10 };
79 typedef std::map<int, KQueueData*> DescriptorMap;
80 typedef std::vector<KQueueData*> DescriptorList;
82 DescriptorMap m_descriptor_map;
88 DescriptorList m_orphaned_descriptors;
90 DescriptorList m_free_descriptors;
96 struct kevent m_change_set[CHANGE_SET_SIZE];
97 unsigned int m_next_change_entry;
102 void CheckDescriptor(
struct kevent *event);
103 std::pair<KQueueData*, bool> LookupOrCreateDescriptor(
int fd);
104 bool ApplyChange(
int fd, int16_t filter, uint16_t flags,
105 KQueueData *kqueue_data,
bool apply_immediately);
106 bool RemoveDescriptor(
int fd, int16_t filter);
108 static const int MAX_EVENTS;
109 static const unsigned int MAX_FREE_DESCRIPTORS;
115 #endif // COMMON_IO_KQUEUEPOLLER_H_ A time interval, with usecond accuracy.
Definition: Clock.h:138
KQueuePoller(ExportMap *export_map, Clock *clock)
Create a new KQueuePoller.
Definition: KQueuePoller.cpp:89
Manages timer events.
Definition: TimeoutManager.h:45
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
A container for the exported variables.
Definition: ExportMap.h:324
A BidirectionalFileDescriptor that also generates notifications when closed.
Definition: Descriptor.h:282
Definition: KQueuePoller.cpp:46
bool AddReadDescriptor(class ReadFileDescriptor *descriptor)
Register a ReadFileDescriptor for read events.
Definition: KQueuePoller.cpp:133
Definition: ExportMap.h:176
Export variables on the http server.
An implementation of PollerInterface that uses kevent / kqueue.
Definition: KQueuePoller.h:51
bool Poll(TimeoutManager *timeout_manager, const TimeInterval &poll_interval)
Poll the Descriptors for events and execute any callbacks.
Definition: KQueuePoller.cpp:226
Used to get the current time.
Definition: Clock.h:242
bool RemoveReadDescriptor(class ReadFileDescriptor *descriptor)
Unregister a ReadFileDescriptor for read events.
Definition: KQueuePoller.cpp:188
Represents a file descriptor that supports reading data.
Definition: Descriptor.h:140
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
bool AddWriteDescriptor(class WriteFileDescriptor *descriptor)
Register a WriteFileDescriptor to receive ready-to-write events.
Definition: KQueuePoller.cpp:196
The interface for the Poller classes.
Definition: PollerInterface.h:70
Represents a point in time with microsecond accuracy.
Definition: Clock.h:191
Represents a file descriptor that supports writing data.
Definition: Descriptor.h:170
bool RemoveWriteDescriptor(class WriteFileDescriptor *descriptor)
Unregister a WriteFileDescriptor for write events.
Definition: KQueuePoller.cpp:222