Hi All,
I’m trying to write a workflow that has a sleep that can be cancelled. The thought process was I’d use a Selector, and add a Receive
handler for a channel where I’d send cancel requests. Then I’d add a Default
handler with a workflow.Sleep
call in it. My understanding is that this will only ever run the Default
handler which would block selector.Select
until the end of the timeout, and that the receive handler would be blocked until the end of this call also. Am I going about this the wrong way? A thought I had was that I’d only sleep for a short interval, check if it’s waited the entire time OR the channel received a value and continue on. The only downside to this is that I’m waking a potentially large number of workflows periodically just to check a time instead of letting them sleep and waking them only when I want to (with the channel).
Any suggestions on how I may design this to minimize waking?
A coworker has pointed out I glossed over the api for Timer and that I could just use that paired with AddFuture
and a single call to selector.Select
to achieve this.
Hopefully this blunder of mine helps someone else