[Bf-committers] Wondering about the review of the command port patch...

Ton Roosendaal ton at blender.org
Fri Sep 19 12:24:25 CEST 2008


Hi,

Unfortunately events are not correctly processed in threads.
If I recall well, that's X11 stuff or maybe Ghost design... I 
discovered this when coding threaded render for tiles. Events are not 
processed or detected inside threads.

-Ton-

------------------------------------------------------------------------
Ton Roosendaal  Blender Foundation   ton at blender.org    www.blender.org
Blender Institute BV  Entrepotdok 57A  1018AD Amsterdam The Netherlands

On 19 Sep, 2008, at 12:09, Jean-Luc Peurière wrote:

>
> 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
>
>
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>



More information about the Bf-committers mailing list