Re: asynchronous execution, was Re: implementing a set of queue-processing servers

[email protected] (Rob Nagler) Tue, 26 Nov 2002 07:08:54 -0700
Newsgroups perl.p5ee
Organization bivio Software Artisans, Inc. <http://www.bivio.biz>
Message-ID <[email protected]>
Bas A.Schulte writes:
> still is something I haven't figured out. Basically, I need some way to 
> coordinate the children so each child can find out what the other 
> children are doing.

Use a table in your database.  The DB needs to support row level
locking (we use Oracle).   Here's an example:

    insert into resource_lock_t (instance_count) values (1)

Don't commit yet.  Rather, right before committing, delete the row:

    delete from resource_lock_t where instance_count = 1

Anybody waiting for instance_count #1 will block until the delete
happens.  You only allow up to four inserts (instance_count is the
primary key).

Rob