[sf-perl] threads, threads::shared, and multiple locked variables
not.com at gmail.com
Thu Jul 9 14:40:45 PDT 2020
How about code with # what goes here? comments
I'm a little fuzzy on what the question is. It sounds a little like
the old-school "select" call that takes a bit vector representing file
handles, which paused and then filled 3 other bit vectors saying which
handles were ready to read, write, or had an exception-is that what
the question is-using "threads" mechanisms to signal which of several
things are ready?
perldoc -f select shows what I remember as similar:
my ($nfound, $timeleft) =
select(my $rout = $rin, my $wout = $win, my $eout = $ein, $timeout);
...my go-to in these situations is to `use MCE;` and figure out which
of its many idioms applies...
On Wed, Jul 8, 2020 at 7:45 PM David Christensen
<dpchrist at holgerdanske.com> wrote:
> I have been experimenting with concurrent programming with Perl,
> threads, and threads::shared. I have successfully used a shared
> variable, lock(), cond_wait(), and cond_broadcast() to ensure
> thread-safe access to one shared resource.
> I would now like to ensure thread-safe access to multiple shared
> resources. Specifically, if a thread desires access to any one of
> several shared resources, how can it block, wake up when one resource is
> available (and locked), and determine which resource to access?
> SanFrancisco-pm mailing list
> SanFrancisco-pm at pm.org
More information about the SanFrancisco-pm