-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wakeup and yields must be matched with expected state. Reaps and deinits should now be memory safe. And some other improvements.
- Loading branch information
Showing
7 changed files
with
153 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
# CORO API | ||
|
||
:::warning | ||
## Paired context switches | ||
|
||
This part of the API is likely to change. | ||
To yield running task to the caller use the following. | ||
The function takes a enum value as a argument representing the yield state of the task. | ||
|
||
```zig | ||
coro.yield(SomeEnum.value); | ||
``` | ||
|
||
To continue running the task from where it left, you need to issue the same enum value to the following function. | ||
If the task currently isn't being yielded in the supplied state, the call is no-op. | ||
|
||
::: | ||
```zig | ||
coro.wakeupFromState(task, SomeEnum.value); | ||
``` | ||
|
||
This is the preferred way to handle the control flow between tasks. | ||
|
||
## Context switches | ||
## Canceling IO | ||
|
||
To yield running task to the caller use the following. | ||
While it's possible to cancel IO by using the `aio.Cancel` operations. It is also possible to cancel | ||
all IO operations currently blocking a task by doing the following. | ||
If the task currently isn't being yielded by IO then the call is no-op. | ||
|
||
```zig | ||
coro.yield(); | ||
coro.wakeupFromIo(task); | ||
``` | ||
|
||
To continue running the task from where it left, use the following. | ||
This can also be used to cancel any IO operations. | ||
## Unpaired wakeup | ||
|
||
Sometimes it's useful to be able to wakeup the task from any yielding state. | ||
|
||
```zig | ||
coro.wakeup(); | ||
coro.wakeup(task); | ||
``` | ||
|
||
In this case the task will wake up no matter what its yielding state is currently. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.