[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] How to make a eventloop similiar to select() with a timeout of 1sec



The server operates in a mode that basically can be described as following:

while(1) {
do_some_global_stuff();

gather_possible_user_input_and_send_output():

executing_only_one_command_for_each_client_in_sequence();

do_some_other_global_stuff();
}

I thought about adding a few periodic event and convert the whole
while(1) loop to event loop. However I am worried about loss of strict
sequencing  (note that I havn't thought in details whether that is
actually important or not), since

gather_possible_user_input_and_send_output() here is basically pure
network IO, them happening in parallel of logic execution should
probably be fine (and the old select() is not really that fair to all
users either).  But any ideas you have will be much appreciated. .

On Mon, Jun 24, 2013 at 10:51 AM, Zack Weinberg <zackw@xxxxxxxxx> wrote:
> On Mon, Jun 24, 2013 at 3:52 AM, åéé <sunyucong@xxxxxxxxx> wrote:
>> select() with a timeout of 1 second.
>>
>> basically I want to wait for as long as 1 second of possible events and move
>> on to do other stuff in while(1) loop.
>
> Moving up a level in design space, what is this "other stuff" you need
> to do after waiting at most one second?  I ask because it might make
> sense to do it on a periodic evtimer *instead*, thus allowing you to
> stay inside event_base_loop indefinitely.  That's more in keeping with
> the design of the library.
>
> zw
> ***********************************************************************
> To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
> unsubscribe libevent-users    in the body.
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.