Skip to content

readme: add some clarifications regarding return types #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Stacktrace:
@ REPL[3]:1
```

Note regarding the return type of `@spawn`:
* `Threads.@spawn` returns a value of the concrete type `Task`
* In contrast, the return type of `StableTasks.@spawn` may depend on any and all of the following:
* the configuration of type inference in the Julia compiler
* the return type of the input function
* in particular, `typeof(StableTasks.@spawn 3) != typeof(StableTasks.@spawn 3.0)`, because `typeof(3) !== typeof(3.0)`

## `StableTasks.@spawnat`

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.
Expand All @@ -40,6 +47,8 @@ julia> @inferred fetch(t)
4
```

The note regarding the return type of `@spawn` also applies here.

## `StableTasks.@fetch` and `StableTasks.@fetchfrom`

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