lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks, good stuff.  One question:

Note that cancel() is a synchronous function, only queueing a request to cancel the nursery. It won't propagate until the code calling cancel() yields execution.

Why was it done that way?  Would it have been possible to just have cancel() throw an exception to immediately stop the child task?  I'm thinking this might lead to surprising behavior because (IIUC) calling cancel won't interrupt the thread and so subsequent code will still get executed, e.g.

if not should_launch_missles then
  nursery.cancel()
end
launch_missles()

David

On Sun, Oct 2, 2022 at 9:28 AM John Belmonte <john@neggie.net> wrote:
I've posted part 3, which fleshes out nursery cancellation:

  https://gist.github.com/belm0/20bc069ca676fcfc591f29930069f788