Closed schlichtanders closed 5 months ago
In certain cases, yes, you can use Dagger.@spawn
like either Threads.@spawn
and @async
, as it can express a function executed asynchronously either on the same thread, or a different one. However, the exact semantics differ in significant ways. Some of those differences are:
Dagger.@spawn
synchronization is performed implicitly, based on the passed arguments and any surrounding "task queues" that modify task synchronization behaviorDagger.spawn_datadeps
Threads.@spawn
and @async
run multiple tasks per thread
The current documentation of
@aync
includes this warningHence a natural question is whether
Dagger.@spawn
can also be used as a better alternative of@async
. This would be so cool, as the whole concurrence interface would be unified.If this indeed works, it would be great to have this somewhere obvious in the documentation.