From doomvox at gmail.com Sat Jul 4 12:20:19 2020 From: doomvox at gmail.com (Joseph Brenner) Date: Sat, 4 Jul 2020 12:20:19 -0700 Subject: [sf-perl] the next Raku study group is on the 12th Message-ID: After taking a break for the weekend of the 4th, we'll be back with the Raku study group that time forgot. Sunday at 2pm, via zoom. With a free account, zoom technically limits meeting length to 40mins, so I'm scheduling three meetings at the top of the hour for 2pm, 3pm, 4pm. If they're enforcing the limit, we'll take 20 minute breaks from the video and then resume (if they're not enforcing it, we'll just stay in the first meeting). RSVP if you like: https://www.meetup.com/San-Francisco-Perl/events/271718963/ 2pm: https://us04web.zoom.us/j/73585912227?pwd=ZHRzUWk3R3lWRER5NUZpZSsvN1BPZz09 3pm: https://us04web.zoom.us/j/79384981433?pwd=bXZ1U1FEK0lNSHlyRmFab1RIc0poQT09 4pm: https://us04web.zoom.us/j/77506196681?pwd=TVZpSkVnUFMxNUVRTDhBRlJWRkx1UT09 From dpchrist at holgerdanske.com Wed Jul 8 16:38:50 2020 From: dpchrist at holgerdanske.com (David Christensen) Date: Wed, 8 Jul 2020 16:38:50 -0700 Subject: [sf-perl] threads, threads::shared, and multiple locked variables Message-ID: <5a1f2478-0bbc-73f0-f019-575c9279a403@holgerdanske.com> sanfrancisco-pm: 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? David From not.com at gmail.com Thu Jul 9 14:40:45 2020 From: not.com at gmail.com (yary) Date: Thu, 9 Jul 2020 17:40:45 -0400 Subject: [sf-perl] threads, threads::shared, and multiple locked variables In-Reply-To: <5a1f2478-0bbc-73f0-f019-575c9279a403@holgerdanske.com> References: <5a1f2478-0bbc-73f0-f019-575c9279a403@holgerdanske.com> Message-ID: 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... -y On Wed, Jul 8, 2020 at 7:45 PM David Christensen wrote: > > sanfrancisco-pm: > > 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? > > > David > _______________________________________________ > SanFrancisco-pm mailing list > SanFrancisco-pm at pm.org > https://mail.pm.org/mailman/listinfo/sanfrancisco-pm From dpchrist at holgerdanske.com Thu Jul 9 17:08:18 2020 From: dpchrist at holgerdanske.com (David Christensen) Date: Thu, 9 Jul 2020 17:08:18 -0700 Subject: [sf-perl] threads, threads::shared, and multiple locked variables In-Reply-To: References: <5a1f2478-0bbc-73f0-f019-575c9279a403@holgerdanske.com> Message-ID: <8634a35e-99fa-f4f5-9b7e-d2a23c71fc57@holgerdanske.com> On 2020-07-09 14:40, yary wrote: > On Wed, Jul 8, 2020 at 7:45 PM David Christensen 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? > 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); Yes, that's the idea -- except that I am working with shared variables [1], rather than file handles. > ...my go-to in these situations is to `use MCE;` and figure out > which of its many idioms applies... MCE [2] appears to provide a framework for creating multiple identical workers and partitioning work among them (?). My question is more related to first principles of concurrent programming. I am attempting to create a general-purpose Perl library for flow-based programming (FBP) [3], whereby multiple independent "processes" send data "items" to each other via communication "connections" and work together as a overall program. FBP's are easily represented by directed graphs -- "processes" are nodes (boxes) and "connections" are edges (arrows). For example, here is a FBP to read a file (src), compress the contents, tee the compressed stream into two streams, write the first duplicate stream to a file (dst.gz), checksum the second duplicate stream, and write the checksum to a file (dst.gz,md5): +-----+ -> write(dst.gz) read(src)-> compress-> | tee | +-----+ -> checksum -> write(dst.gz.md5) I use 'threads' to create and manage one thread for each process and I use 'threads::shared' to create and manage one array for each connection. These modules work for simple programs like the above with processes that have single inputs and single or multiple outputs, but, in general, FBP's will include processes with multiple inputs: ... proc1 -> +------+ | func | ... ... proc2 -> +------+ So, I need a mechanism for a thread to go to sleep on multiple shared variables, wake up when one of those variables signals, and then know which variable woke it up. I am starting to believe that my question is really a feature request for threads::shared (and/or Perl?). I am open to alternative approaches, but the goal is a general-purpose FBP library. (As a work-around, I am implementing a polling solution with a configurable sleep delay.) (Perhaps I could build a work-around using file handles and 'select', but file handles are scarce resources and a large FBP could consume many.) David [1] https://perldoc.perl.org/threads/shared.html [2] https://metacpan.org/pod/distribution/MCE/lib/MCE.pod [3] https://en.wikipedia.org/wiki/Flow-based_programming From doomvox at gmail.com Fri Jul 17 16:24:50 2020 From: doomvox at gmail.com (Joseph Brenner) Date: Fri, 17 Jul 2020 16:24:50 -0700 Subject: [sf-perl] Suddenly, the Raku Study Group Message-ID: No one expects the online Raku study group. Sunday at 2pm, via zoom. RSVP to: https://www.meetup.com/San-Francisco-Perl/events/271993517/ With a free account, zoom technically limits meeting length to 40mins, so I'm scheduling three meetings at the top of the hour for 2pm, 3pm, 4pm. If they're enforcing the limit, we'll take 20 minute breaks from the video and then resume (if they're not enforcing it, we'll just stay in the first meeting). 2pm: https://us04web.zoom.us/j/76633459313?pwd=eW50SDhUNXUxVzE5alRKTUFXUHZoUT09 3pm: https://us04web.zoom.us/j/75234854364?pwd=S2hPMk5sYjVSZ3RjZ1JMS3dQajdFQT09 4pm: https://us04web.zoom.us/j/71339073769?pwd=MWZTTEVUMmx5N2lpYTZQQlpDd2V0QT09 From doomvox at gmail.com Fri Jul 24 10:30:27 2020 From: doomvox at gmail.com (Joseph Brenner) Date: Fri, 24 Jul 2020 10:30:27 -0700 Subject: [sf-perl] Raku Study group, Sunday July26th, 2pm Message-ID: What song did the sirens sing, and when will the next Raku study group be? Sunday at 2pm, via zoom. https://us04web.zoom.us/j/77192674311?pwd=VzQrNUQ4RU4xZG9qWm9EUlBsQllOdz09 Password: 4RakuRoll From doomvox at gmail.com Thu Jul 30 13:44:47 2020 From: doomvox at gmail.com (Joseph Brenner) Date: Thu, 30 Jul 2020 13:44:47 -0700 Subject: [sf-perl] Raku study group, Sunday Aug 2nd, 2pm Message-ID: It's alive! The Raku study group : Sunday, August 2nd, at 2pm, via zoom. https://us04web.zoom.us/j/73188828798?pwd=MWdIbVo3U1hpQStvZUo3YjRicGtrZz0909 Password: 4RakuRoll RSVP: https://www.meetup.com/San-Francisco-Perl/events/272258217/