gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying live video -- how to notify main loop from another thread


From: Richard Frith-Macdonald
Subject: Re: Displaying live video -- how to notify main loop from another thread?
Date: Fri, 9 Jul 2010 14:59:18 +0100

On 9 Jul 2010, at 14:42, Marek Peca wrote:

>>>> It is not required, however GNUstep does need to know that the app is 
>>>> multithreaded.  (..)
> 
> On 9 Jul 2010, at 13:56, Richard Frith-Macdonald wrote:
>> (..)
>> There are quite a few things which use NSThread, and if you call them from 
>> an unknown thread you are asking for trouble.
>> 
>> Currently the API to handle this is to call GSRegisterCurrentThread() in 
>> each thread before it calls any other gnustep code, and call 
>> GSUnregisterCurrentThread() when your thread is about to exit.
>> 
>> You do not need to do this for any thread which doesn't use GNUstep though.
> 
> 
> So, if I'm getting it right, I should follow the following scenario:
> 
> - create several threads using pthreads
> - for each of them (probably only one of them), call 
> GSRegisterCurrentThread() at the beginning
> - then, I may call NSView -setNeedsDisplay:, but it currently does not work, 
> so I should use performSelectorOnMainThread... instead
> OK?

Yes ...though of course you must have a main thread too ... 

In fact the simplest solution is to:

Start with your main thread and have it
1. Use the NSThread API to create the other thread you will be using to monitor 
for changes, then
2. Use the pthreads api to create any other threads which won't be interacting 
with GNUstep, then
3. Run the main event loop.

If you only need two GNUstep threads (the main one handling the display, and 
the one monitoring for changes that need displaying), then you can avoid 
needing to register/unregister any other threads.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]