Re: Glib::Dispatcher1<T>



On Friday 19 January 2007 07:44, Daniel Elstner wrote:
> Hello everyone,
>
> I recently learned that the POSIX memory visibility rules aren't as
> strict as I thought them to be (thanks to Chris for pointing this out).
> Given this, I'm now considering an API addition to glibmm, namely a
> Glib::Dispatcher1<T> template that allows passing an argument to the
> receiving end.  What I have in mind is this:

[snip]

It will be necessary to provide synchronisation of course - Glib::SignalIdle 
does this through attaching to the glib main loop, whereas Glib::Dispatcher 
is only attached once and thereafter can be invoked from time to time with 
(under your proposal) different arguments.  I would tend to use a semaphore 
in this use (after writing the argument the signalling thread calls 
sem_post(), a release, and before reading the argument the main loop 
dispatching thread calls sem_wait(), an acquire), but glib doesn't have them.

Are you going to put a mutex around the argument in the sending and receiving 
thread?

What I tend to do for passing arguments to dispatcher-type invocations is use 
a std::queue object with mutex locking of the queue.  That would also be a 
means of implementing your templated Dispatcher proposal and would not be 
restricted to built-in types.

Chris




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