> Jenda,
> 
> Thanks for your input, but I do believe I need to clear up some parts.
> 
> I use a semaphore for synchronizing between parent and child(s). The
> semaphore starts with a initial value of, say 5 ( the maximum number of
> child processes I want to handle simultaneously), and the parent process
> wait() checkes to see if it is non-zero, and if so, decrements it by 1, and
> continues.
> If it is zero, it waits until it becomes non-zero. It is the responsibility
> of the child proces to increment the semaphores value, indicating the
> parent proces that it has ended. If the parent proces itself executes a
> release(), it increments the semaphore! This would indicate that it can
> continue, regardles of the number of childs actually spawned.

You are right. Seems I mixed it up quite a bit. I've been working on 
the invalid handle problem, introduced one more  wait() so I had to 
add one more release() ... god knows what was I thinking about.
(probably girls ..)

Even I do mistakes ;-)

> My knowledge about the bless() part isn't deep enough (yet) to understand
> what you're meaning, but I do think this wil be helpfull.
> I changed the code again, leaving out the wait() part for the child, and
> the release for the parent, and voila... IT WORKED!!
> So it must be the bless() part that does it.
> 
> Again, THANKS for your input.
> 
> Guus

In one sentence "The bless magic makes sure the shared object is not 
destroyed by the children as they exit." 

And how does it work? 

If there are no more references to an object, it is destroyed. To 
allow the object to close open connections or handles Perl calls
its method DESTROY() if it exists. Since I do not want this function 
to be called by the child threads I have to cheat. I have to change 
the "type" of that object so that Perl will not be able to find the 
method. That is "bless" it to a not existing package.

Jenda

== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==
: What do people think?
What, do people think?  :-)
             -- Larry Wall in <[EMAIL PROTECTED]>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to