#IO Fire and Forget

1 messages · Page 1 of 1 (latest)

earnest tusk
#

What is the recommended pattern to basically deal with fire and forget tasks that do their own error handling? Basically what was previously handled via threadpool.spawn?

The threadpool is gone and io.concurrent still returns a future which, at least in some of the implementations, needs to be awaited to ensure some cleanup happens?

subtle rain
#

Io.Group is generally the recommended replacement

earnest tusk
#

Thanks. I'm going to use that for now as it truly looks almost perfect:

/// The resources associated with each task are *guaranteed* to be released when
/// the individual task returns, as opposed to when the whole group completes or
/// is awaited. For this reason, it is not a resource leak to have a long-lived
/// group which concurrent tasks are repeatedly added to.

Just worried about how the comment continues (doesn't seem to apply to the threaded implementation though, so not an issue right now):

///However, asynchronous
/// tasks are not guaranteed to run until `Group.await` or `Group.cancel` is
/// called, so adding async tasks to a group without ever awaiting it may leak
/// resources.

But I guess that is indeed the replacement for thread.pool for now?

subtle rain
#

yea dont think theres really anything else currently

#

Group + Io.Threaded is the intention

earnest tusk
#

Ok, thanks again

cerulean smelt
#

proper thread pool replacement would be Io.Queue + Io.Group + group.concurrent for N workers