diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:09:58 +0900 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:09:58 +0900 |
commit | 24cf53ad6eaa0eb9a873b909e932d95417f52d2c (patch) | |
tree | 0d2f19a76536d09d0fe6e22874ce572eda70eccd /src/poller_base.hpp | |
parent | 0641ffa5e9588dd7daaf389c40a213994fe4b1b1 (diff) |
io_thread_t merged with poller_base_t
The relationship of these two classes was 1:1.
Thus one of them was obsolete.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/poller_base.hpp')
-rw-r--r-- | src/poller_base.hpp | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/poller_base.hpp b/src/poller_base.hpp index e63f203..2388fad 100644 --- a/src/poller_base.hpp +++ b/src/poller_base.hpp @@ -25,11 +25,15 @@ #include "fd.hpp" #include "clock.hpp" +#include "object.hpp" +#include "mailbox.hpp" #include "atomic_counter.hpp" namespace xs { + class ctx_t; + // Handle of a file descriptor within a pollset. typedef void* handle_t; @@ -50,12 +54,12 @@ namespace xs virtual void timer_event (handle_t handle_) = 0; }; - class poller_base_t + class poller_base_t : public object_t, public i_poll_events { public: // Create optimal poller mechanism for this environment. - static poller_base_t *create (); + static poller_base_t *create (xs::ctx_t *ctx_, uint32_t tid_); virtual ~poller_base_t (); @@ -66,6 +70,9 @@ namespace xs void start (); void stop (); + // Returns mailbox associated with this I/O poller. + mailbox_t *get_mailbox (); + virtual handle_t add_fd (fd_t fd_, xs::i_poll_events *events_) = 0; virtual void rm_fd (handle_t handle_) = 0; virtual void set_pollin (handle_t handle_) = 0; @@ -82,9 +89,14 @@ namespace xs // Cancel the timer identified by the handle. void rm_timer (handle_t handle_); + // i_poll_events implementation. + void in_event (fd_t fd_); + void out_event (fd_t fd_); + void timer_event (handle_t handle_); + protected: - poller_base_t (); + poller_base_t (xs::ctx_t *ctx_, uint32_t tid_); // Called by individual poller implementations to manage the load. void adjust_load (int amount_); @@ -95,6 +107,8 @@ namespace xs private: + void process_stop (); + // Clock instance private to this I/O thread. clock_t clock; @@ -111,6 +125,12 @@ namespace xs // registered. atomic_counter_t load; + // I/O thread accesses incoming commands via this mailbox. + mailbox_t mailbox; + + // Handle associated with mailbox' file descriptor. + handle_t mailbox_handle; + poller_base_t (const poller_base_t&); const poller_base_t &operator = (const poller_base_t&); }; |