On Wed, 3 Sep 2003 [EMAIL PROTECTED] wrote:

> guy keren wrote:
> > that into account. assuming the GUI library is not thread-safe, you'll
> > need to make sure you perform all GUI operations from within one thread
> > only - this requires some 'thread-to-thread' delegation mechanism - not
> > hard to implement, but requires _some_ time.
>
> Why is 'thread-to-thread' delegation required?
>
> What's wrong with Mutexes at the right spots, so only one thread gets
> to run the "critical sections" at any point in time?

because normally, the GUI library runs inside a 'main loop' that waits for
events and handles them. so you'll dedicate one thread to run this 'main
loop'. and since this thread might wake up whenever, in order to handle a
new event, and this thread cannot wait on a mutex (cause no one told it
to) - so you'll not want to start messing with the GUI library from within
another thread. what you'll normally do (again, all this - iff the GUI
library isn't thread safe) is that other threads that want to update the
GUI will delegate the operatoin to the main thread (e.g. writing a
'command' on a GUI commands queue, and waking this thread by writing a
byte into a pipe, and having the GUI thread add this pipe's file
descriptor to the set of file descriptors it select(2)-s on. (all GUI
library i saw have a method to ask the main loop to add file descriptors
to its select()/poll() loop).

-- 
guy

"For world domination - press 1,
 or dial 0, and please hold, for the creator." -- nob o. dy


=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to