@@ -45,16 +45,14 @@ static void event_init(ACL_EVENT *eventp, int fdsize,
4545
4646 eventp -> delay_sec = delay_sec + delay_usec / 1000000 ;
4747 eventp -> delay_usec = delay_usec % 1000000 ;
48- /*
49- acl_ring_init(&eventp->used_ring);
50- acl_ring_init(&eventp->slot_ring);
51- */
5248
5349 acl_ring_init (& eventp -> timer_head );
5450 eventp -> timer_keep = 0 ;
5551 SET_TIME (eventp -> present );
5652 SET_TIME (eventp -> last_debug );
5753
54+ eventp -> check_inter = 100000 ; /* default: 100 ms */
55+
5856 if (eventp -> init_fn )
5957 eventp -> init_fn (eventp );
6058}
@@ -214,18 +212,21 @@ ACL_EVENT *acl_event_new_wmsg(unsigned int nMsg)
214212#endif
215213}
216214
217- ACL_EVENT * acl_event_new (int event_mode , int use_thr , int delay_sec , int delay_usec )
215+ ACL_EVENT * acl_event_new (int event_mode , int use_thr ,
216+ int delay_sec , int delay_usec )
218217{
219218 const char * myname = "acl_event_new" ;
220219 ACL_EVENT * eventp = NULL ;
221220
222221 if (use_thr ) {
223222 switch (event_mode ) {
224223 case ACL_EVENT_SELECT :
225- eventp = acl_event_new_select_thr (delay_sec , delay_usec );
224+ eventp = acl_event_new_select_thr (delay_sec ,
225+ delay_usec );
226226 break ;
227227 case ACL_EVENT_KERNEL :
228- eventp = acl_event_new_kernel_thr (delay_sec , delay_usec );
228+ eventp = acl_event_new_kernel_thr (delay_sec ,
229+ delay_usec );
229230 break ;
230231 case ACL_EVENT_POLL :
231232 eventp = acl_event_new_poll_thr (delay_sec , delay_usec );
@@ -260,7 +261,13 @@ ACL_EVENT *acl_event_new(int event_mode, int use_thr, int delay_sec, int delay_u
260261 return eventp ;
261262}
262263
263- void acl_event_fire_hook (ACL_EVENT * eventp , void (* fire_begin )(ACL_EVENT * , void * ),
264+ void acl_event_set_check_inter (ACL_EVENT * eventp , int n )
265+ {
266+ eventp -> check_inter = n * 1000 ;
267+ }
268+
269+ void acl_event_set_fire_hook (ACL_EVENT * eventp ,
270+ void (* fire_begin )(ACL_EVENT * , void * ),
264271 void (* fire_end )(ACL_EVENT * , void * ), void * ctx )
265272{
266273 eventp -> fire_begin = fire_begin ;
@@ -282,6 +289,7 @@ void acl_event_free(ACL_EVENT *eventp)
282289 acl_ring_detach (& timer -> ring );
283290 acl_myfree (timer );
284291 }
292+
285293 acl_myfree (eventp -> fdtabs );
286294 acl_myfree (eventp -> fdtabs_ready );
287295 free_fn (eventp );
@@ -300,7 +308,8 @@ void acl_event_enable_read(ACL_EVENT *eventp, ACL_VSTREAM *stream,
300308 if (sockfd == ACL_SOCKET_INVALID )
301309 acl_msg_fatal ("%s(%d): sockfd(%d) invalid" ,
302310 myname , __LINE__ , sockfd );
303- eventp -> enable_read_fn (eventp , stream , read_timeout , callback , context );
311+ eventp -> enable_read_fn (eventp , stream , read_timeout ,
312+ callback , context );
304313}
305314
306315void acl_event_enable_write (ACL_EVENT * eventp , ACL_VSTREAM * stream ,
@@ -311,13 +320,15 @@ void acl_event_enable_write(ACL_EVENT *eventp, ACL_VSTREAM *stream,
311320 if (sockfd == ACL_SOCKET_INVALID )
312321 acl_msg_fatal ("%s(%d): sockfd(%d) invalid" ,
313322 myname , __LINE__ , sockfd );
314- eventp -> enable_write_fn (eventp , stream , write_timeout , callback , context );
323+ eventp -> enable_write_fn (eventp , stream , write_timeout ,
324+ callback , context );
315325}
316326
317327void acl_event_enable_listen (ACL_EVENT * eventp , ACL_VSTREAM * stream ,
318328 int read_timeout , ACL_EVENT_NOTIFY_RDWR callback , void * context )
319329{
320- eventp -> enable_listen_fn (eventp , stream , read_timeout , callback , context );
330+ eventp -> enable_listen_fn (eventp , stream , read_timeout ,
331+ callback , context );
321332}
322333
323334void acl_event_disable_read (ACL_EVENT * eventp , ACL_VSTREAM * stream )
0 commit comments