On Wed, Nov 27, 2002 at 06:07:10PM -0500, Al Tobey wrote:
> Hi, I posted a bit ago about session locking.  I had a half-witted idea
> then for how to do it, and now I have something even worse.  Now, I'll
> share the worse idea :)

[...]

> Now, onto the locking mechanism.  Basically, I create a new POE::Session
> for managing the locking, and most importantly, causing a call to the
> lock to block.  Postbacks play a large part in this.  Here's the package
> .... it's ugly, but currently working.

[...]

> To check if a value is locked, just call $lock->locked( 'name' );.  To
> have an event block on a lock (without holding up the whole kernel) ,
> you'd use $lock->wait( $_[SESSION]->postback( 'my_event', @arguments ),
> 'client' );.
> Of course, if this process were running in threads, it would have to use
> lock() or sem(get|op|set|ctl) to protect the %value hash, but since I'm
> using a monolithic process, I get away with it.
> 
> Anyways, just posting this to see if anybody thinks its stupid or has
> use for something like this.  Maybe I should look into IKC ...?

You should consider releasing that as a general module.  Locking is
just one form of session synchronization, which is generally useful
and not well explored in POE.

Semaphores would also be useful, perhaps as tied scalars that generate
events when they reach certain values.

Scatter/gather is a popular synchronization pattern.  Picture several
sessions asynchronously performing parts of a much larger task.  Each
reports its results back to a central clearinghouse, which only fires
an event when all the pieces have been put together.

What other synchronization patterns are generally useful?

IKC lets you pass events across networks, but I don't think it does
locking like you've implemented.

-- Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to