in reply to Semaphores failing to prevent race condition
I written a lot of threaded perl code over the last 8 or 9 years, and I've never had occasion to use Thread::Semaphore. To me it seems to be a very complicated (and apparently broken) way to do something very simple.
I would ditch that module in favour of a very simple mechanism.
my $outputSem :shared; ... if ($success) { lock $outputSem; erase($input_window); addstr($input_window, $buffer); refresh($input_window); $ptr = length($buffer); curs_to_ptr($input_window, $ptr); } ... sub icb_print { my ($window, $color, $fmt, @args) = @_; my $buf = sprintf ($fmt, @args); lock $outputSem; ... }
No guarantees given I cannot see never mind run most of your code, but that simple change will probably fix your problems.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Semaphores failing to prevent race condition
by Llew_Llaw_Gyffes (Scribe) on Mar 13, 2011 at 19:22 UTC | |
by Llew_Llaw_Gyffes (Scribe) on Mar 16, 2011 at 11:54 UTC | |
by BrowserUk (Patriarch) on Mar 16, 2011 at 17:00 UTC |