exodist has asked for the wisdom of the Perl Monks concerning the following question:
my $Buffer; #The buffer that needs to be filled. push(@Que, \$Buffer); #Put the buffer into the que, this is a line I p +ut in for simplicty, the actual request is a lot more complicated. while (1) #Infinite loop { threads->yield(); #Yield each iteration lock($Buffer); #Lock the buffer, this way if data is still being p +laced intot eh buffer in the other thread it will be locked there and + we cannot get data early. will it be unlocked for the next iteration +? or is the loop not considered leaving it's own {} per iteration? last if ($Buffer); #If the buffer is filled continue. }
--------------------------------------
I would rather take 30 minutes to re-invent the wheel then take 30 days to learn how to use someone else's. Before pestering me about my re-invention prepare to defend yourself with a way of learning how to use the wheel in less time than it takes for me to make one, one that I might add is specialized to my specific task!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need a thread to wait until a buffer is full.
by Trizor (Pilgrim) on Jul 24, 2007 at 21:54 UTC | |
|
Re: need a thread to wait until a buffer is full.
by BrowserUk (Patriarch) on Jul 24, 2007 at 23:04 UTC | |
by archfool (Monk) on Jul 25, 2007 at 02:42 UTC | |
by BrowserUk (Patriarch) on Jul 25, 2007 at 05:32 UTC | |
by exodist (Monk) on Jul 25, 2007 at 07:12 UTC | |
by zentara (Cardinal) on Jul 25, 2007 at 12:17 UTC | |
| |
|
Re: need a thread to wait until a buffer is full.
by archfool (Monk) on Jul 24, 2007 at 21:42 UTC | |
by exodist (Monk) on Jul 25, 2007 at 07:27 UTC |