mirror of
https://github.com/zeromq/libzmq.git
synced 2025-11-07 05:58:45 +01:00
Problem: poller item lookup can be simplified
Solution: Extract generic find function
This commit is contained in:
@@ -86,6 +86,17 @@ class socket_poller_t
|
||||
bool check_tag () const;
|
||||
|
||||
private:
|
||||
typedef struct item_t
|
||||
{
|
||||
socket_base_t *socket;
|
||||
fd_t fd;
|
||||
void *user_data;
|
||||
short events;
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||
int pollfd_index;
|
||||
#endif
|
||||
} item_t;
|
||||
|
||||
static void zero_trail_events (zmq::socket_poller_t::event_t *events_,
|
||||
int n_events_,
|
||||
int found_);
|
||||
@@ -103,6 +114,15 @@ class socket_poller_t
|
||||
uint64_t &now_,
|
||||
uint64_t &end_,
|
||||
bool &first_pass_);
|
||||
static bool is_socket (const item_t &item, const socket_base_t *socket_)
|
||||
{
|
||||
return item.socket == socket_;
|
||||
}
|
||||
static bool is_fd (const item_t &item, fd_t fd_)
|
||||
{
|
||||
return !item.socket && item.fd == fd_;
|
||||
}
|
||||
|
||||
int rebuild ();
|
||||
|
||||
// Used to check whether the object is a socket_poller.
|
||||
@@ -111,17 +131,6 @@ class socket_poller_t
|
||||
// Signaler used for thread safe sockets polling
|
||||
signaler_t *_signaler;
|
||||
|
||||
typedef struct item_t
|
||||
{
|
||||
socket_base_t *socket;
|
||||
fd_t fd;
|
||||
void *user_data;
|
||||
short events;
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||
int pollfd_index;
|
||||
#endif
|
||||
} item_t;
|
||||
|
||||
// List of sockets
|
||||
typedef std::vector<item_t> items_t;
|
||||
items_t _items;
|
||||
|
||||
Reference in New Issue
Block a user