Skip to content

Commit ac9844b

Browse files
authored
Merge pull request #9 from nsajko/readme_type_stability
readme: add some clarifications regarding return types
2 parents d2789f0 + f160122 commit ac9844b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ Stacktrace:
2929
@ REPL[3]:1
3030
```
3131

32+
Note regarding the return type of `@spawn`:
33+
* `Threads.@spawn` returns a value of the concrete type `Task`
34+
* In contrast, the return type of `StableTasks.@spawn` may depend on any and all of the following:
35+
* the configuration of type inference in the Julia compiler
36+
* the return type of the input function
37+
* in particular, assuming type inference is precise, `typeof(StableTasks.@spawn 3) != typeof(StableTasks.@spawn 3.0)`, because `typeof(3) !== typeof(3.0)`
38+
* You should **not** write code that relies upon the exact return type of `StableTasks.@spawn` being concrete, or stable across versions. The return type in its parameter is available **only** as an optimization.
39+
3240
## `StableTasks.@spawnat`
3341

3442
The package also provides `StableTasks.@spawnat`, which is similar to `StableTasks.@spawn` but creates a *sticky* task (that won't migrate) on a specific thread.
@@ -40,6 +48,8 @@ julia> @inferred fetch(t)
4048
4
4149
```
4250

51+
The note regarding the return type of `@spawn` also applies here.
52+
4353
## `StableTasks.@fetch` and `StableTasks.@fetchfrom`
4454

4555
For convenience, and in analogy to at Distributed.jl, we also provide `@fetch` and `@fetchfrom` macros:

0 commit comments

Comments
 (0)