Skip to content

Commit 05582dc

Browse files
committed
update README
1 parent a502db8 commit 05582dc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

README.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,28 @@ StableTasks is a simple package with one main API `StableTasks.@spawn` (not expo
55
It works like `Threads.@spawn`, except it is *type stable* to `fetch` from.
66

77
``` julia
8-
julia> Core.Compiler.return_type(() -> fetch(StableTasks.@spawn 1 + 1), Tuple{})
9-
Int64
8+
julia> using StableTasks, Test
9+
10+
julia> @inferred fetch(StableTasks.@spawn 1 + 1)
11+
2
1012
```
1113
versus
1214

1315
``` julia
14-
julia> Core.Compiler.return_type(() -> fetch(Threads.@spawn 1 + 1), Tuple{})
15-
Any
16+
julia> @inferred fetch(Threads.@spawn 1 + 1)
17+
ERROR: return type Int64 does not match inferred return type Any
18+
Stacktrace:
19+
[1] error(s::String)
20+
@ Base ./error.jl:35
21+
[2] top-level scope
22+
@ REPL[3]:1
1623
```
1724

1825
The package also provides `StableTasks.@spawnat` (not exported), which is similar to `StableTasks.@spawn` but creates a *sticky* task (it won't migrate) on a specific thread.
1926

2027
```julia
2128
julia> t = StableTasks.@spawnat 4 Threads.threadid();
2229

23-
julia> fetch(t)
30+
julia> @inferred fetch(t)
2431
4
2532
```

0 commit comments

Comments
 (0)