On Fri, May 26, 2006 at 04:48:46PM +0200, Erik Johansson wrote:
> CPlugin::run()
> {
>   while (doRun)
>   {
>     if (hasPendingEvents()) 
>       processEvents();
>     else
>       // sleep, wait for a condition or do nothing i.e. busy wait
>   }
> }

See below for comments on this.

> What about, instead of using pipes, the daemon just appends events to the 
> plugin's event queue? This way plugins don't have to call 
> licqDaemon->PopPluginEvent(), they just process their own local queue. It 
> would make it fairly simple to implement asynchronous signals: the daemon 
> copies the event, appends it to the plugin's queue and continues with the 
> next callback. All callbacks that don't modify the event data could be async.

For the daemon to append events to the plugin's event queue, it will
need to be thread-safe. Which isn't a problem since the daemon will
have a mutex for that, which means it is the only part that has write
access to the plugin's event queue. But the thing is with your above
CPlugin::hasPendingEvents(), it can easily be done with a pipe and a
select. After the daemon writes to the event queue, it has to tell the
plugin that there is a new event waiting. Using a pipe is very simple
way to accomplish the IPC that we need. And, if the signal is to be
asynchronous, the plugin would have to tell the daemon that it won't
modify the event (such as a plugin that logs everything). Is it
worthwhile to implement this, or assume that it won't be asynchronous?

> One thing: shared_ptr isn't thread-safe. If they are supposed to be passed 
> between threads, some kind of wrapper has to be done.

Well, it does have some thread safety:
http://boost.org/libs/smart_ptr/shared_ptr.htm#ThreadSafety 

We just have to ensure that we don't do simultaneous read/write from a
thread and another read or write operation in a different thread.

Jon

-- 
________________________________________________________
Jon Keating                ICQ: 16325723
[EMAIL PROTECTED]               MSN: [EMAIL PROTECTED]
http://www.licq.org        GPG: 2290A71F
http://www.thejon.org      HOME: Minamiashigara, Japan

Attachment: pgp3C9tfsc44X.pgp
Description: PGP signature

Reply via email to