more useful options | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As an exercise in enlightenment, I've been going through Rob Pike's "Go Concurrency Patterns" video, trying to rewrite his examples in Perl 6. Where I'm having trouble, though, is getting Channel.receive to timeout per request. (I can easily make a global timeout for all communication, but I want the timeout to reset after each message comes through.) The following works, but I feel like I should be using something "react/whenever" or something, to make it more idiomatic. PS — Yes, I know, "There's More Than One Way To Do It" (and "If It's Stupid, But It WORKS, It Isn't Stupid!") If this were an actual application, I'd be happy to leave it "as is"; I'm just trying to understand the "More Than One" ways... «grin» However, if I change that to: ... it always runs for ~five seconds, and then exits. (You'd think it would never timeout, since the channel is set to send at least one message every two seconds.) Any idea what I'm missing? [Edit: Refactored "timeout" channel with Promise.in()] In reply to Perl6: react/whenever timeout by OneTrueDabe
|
|