25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include <cx/hash_map.h> |
29 #include <cx/hash_map.h> |
|
30 #include <cx/linked_list.h> |
30 #include "../util/atomic.h" |
31 #include "../util/atomic.h" |
31 |
32 |
32 #include "event.h" |
33 #include "event.h" |
33 |
34 |
34 CxMap *event_handler_map = NULL; |
35 CxMap *event_handler_map = NULL; |
116 |
117 |
117 int ins = ev->current & nev; |
118 int ins = ev->current & nev; |
118 ws_atomic_inc32(&ev->current); |
119 ws_atomic_inc32(&ev->current); |
119 return ev->instances[ins]; |
120 return ev->instances[ins]; |
120 } |
121 } |
|
122 |
|
123 |
|
124 void ev_watchlist_add(EventHandler *h, EVWatchList *elm) { |
|
125 watchlist_add(&h->watchlist_begin, &h->watchlist_end, elm); |
|
126 } |
|
127 |
|
128 void ev_watchlist_remove(EventHandler *h, EVWatchList *elm) { |
|
129 watchlist_remove(&h->watchlist_begin, &h->watchlist_end, elm); |
|
130 } |
|
131 |
|
132 void ev_saf_return(EventHandler *h, Session *sn, Request *rq, int ret) { |
|
133 h->fnreturn[h->numret++] = (EVReturn){ sn, rq, ret }; |
|
134 } |
|
135 |
|
136 void watchlist_add(EVWatchList **begin, EVWatchList **end, EVWatchList *elm) { |
|
137 cx_linked_list_add( |
|
138 (void**)begin, |
|
139 (void**)end, |
|
140 offsetof(EVWatchList, prev), |
|
141 offsetof(EVWatchList, next), |
|
142 elm); |
|
143 } |
|
144 |
|
145 void watchlist_remove(EVWatchList **begin, EVWatchList **end, EVWatchList *elm) { |
|
146 cx_linked_list_remove( |
|
147 (void**)begin, |
|
148 (void**)end, |
|
149 offsetof(EVWatchList, prev), |
|
150 offsetof(EVWatchList, next), |
|
151 elm); |
|
152 } |
|
153 |
|
154 void watchlist_check(EventHandler *h, time_t t) { |
|
155 if(t == 0) { |
|
156 t = time(NULL); |
|
157 } |
|
158 |
|
159 |
|
160 } |