[Bf-committers] Wondering about the review of the command port patch...
Jean-Luc Peurière
jlp at nerim.net
Fri Sep 19 12:09:25 CEST 2008
Le 19 sept. 08 à 08:24, Stéphane SOPPERA a écrit :
>
>> +/**
>> + busy waiting for new events.
>> +static void wait_for_event()
>> +{
>> + while (!mainqtest()) {
>> + PIL_sleep_ms(5); /* sleep for 5 milliseconds */
>> + winlay_process_events(0); /* if there are events in the GHOST
>> queue,
>> + (non-blocking polling of GHOST events)
>> + preprocess them and copy them over
>> + into the Blender main event queue.
>> + */
>> + }
>> +}
>>
> Hi,
>
> Instead of this busy waiting with a 5ms sleep, wouldn't it be
> better to
> use a pthread condition?
> http://www.humbug.org.au/talks/pthreads/pthread_cond.html
>
> That would prevent this hugly busy waiting and enable any thread
> adding
> an event to break the wait on the condition and make the event loop
> handle the new message.
>
this is indeed uggly, and not processor cycles friendly.
More problematic, this may leads to problems on Os X where the event
queue is only awakened on external system events.
Cant you insert what is needed at GHOST level ? Or a message that
stuff is to be read from other threads (it is how we handle
ndof ) ?
having 2 different level event loops potentially sleeping seems bound
to risks.
Jean-Luc Peurière
jlp at nerim.net
More information about the Bf-committers
mailing list