The spawn option is a bit unusual in how it works. Intuitively, it seems dangerous, since it doesn't surface the maximum number of tasks, so it might seem like it can exhaust resources. But of course it's limited by pool_size and can error out with SpawnError::Busy, and will do so by default if sent more than once in parallel (which is also not something I'd expect!).
On the other hand, it can be substituted with a handler that sends a message to a channel that tasks are reading from.
I'm happy to take a stab at a note in the docs describing this nuance, but an alternative would be ditching spawn altogether, incentivising users to just use channels+prespawned tasks instead. What do you think?
The
spawn
option is a bit unusual in how it works. Intuitively, it seems dangerous, since it doesn't surface the maximum number of tasks, so it might seem like it can exhaust resources. But of course it's limited bypool_size
and can error out withSpawnError::Busy
, and will do so by default if sent more than once in parallel (which is also not something I'd expect!).On the other hand, it can be substituted with a handler that sends a message to a channel that tasks are reading from.
I'm happy to take a stab at a note in the docs describing this nuance, but an alternative would be ditching
spawn
altogether, incentivising users to just use channels+prespawned tasks instead. What do you think?