2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
13 m_connections
= new List
;
22 Connection
* Poll::__findConnection (Connection
* c
)
24 m_connections
->first ();
26 if (m_connections
->get () == NULL
)
28 if (((Connection
*) m_connections
->get ()) == c
)
30 m_connections
->next ();
35 Connection
* Poll::__findName (char * str
)
38 m_connections
->first ();
40 c
= (Connection
*) m_connections
->get ();
43 if (EQ (c
->name (), str
))
45 m_connections
->next ();
50 Connection
* Poll::add (Connection
* c
)
52 m_connections
->add (LPCHAR (c
));
56 Connection
* Poll::unlink (Connection
* c
)
58 if (__findConnection (c
))
63 pollfd
* Poll::poll_build (int * nfds
)
72 count
= m_connections
->count ();
73 pull
= CNEW (pollfd
, count
);
74 m_connections
->first ();
76 c
= (Connection
*) m_connections
->get ();
80 pull
[i
].fd
= c
->socket ();
81 pull
[i
].events
= c
->pollFlags();
84 m_connections
->next ();
94 Connection
* Poll::scan ()
102 m_connections
->first ();
104 c
= (Connection
*) m_connections
->get ();
107 if (pull
[p_pos
].revents
) {
108 c
->setRevents (pull
[p_pos
].revents
);
109 pull
[p_pos
].revents
= 0;
113 m_connections
->next ();
119 int Poll::poll (int timeout
)
123 return ::poll (pull
, nfds
, timeout
);
128 return m_connections
->count ();
131 List
* Poll::connections ()