in reply to Re: A per-instance shared queue among forked child processes?
in thread A per-instance shared queue among forked child processes?

That's a great idea that I can't believe I didn't think of. I can create the table in the parent:
$queue_table = 'queue_'.$$; $dbh->do('CREATE TABLE '.$queue_table.' (payload TEXT NOT NULL)');
And then access it from the children after the fork, via $queue_table.

Replies are listed 'Best First'.
Re^3: A per-instance shared queue among forked child processes?
by wind (Priest) on Apr 04, 2011 at 20:27 UTC
    I personally would not create a new table for each instance, but would instead have a static table that contains the key PARENTID or CHILDID depending on if you wanted the queues to be associated to the parent or child.
    my $sth = $dbh->prepare(q{INSERT INTO TABLE QUEUE SET PARENTID=?, PAYL +OAD=?}); $sth->execute($parentid, $payload) or die $dbh->errstr;

    Before each new instance of a parent is run, it should simply scan the table to see if there are any old records left over from a previous process with the same pid.