doc: Document `co_serializable()`.

This commit is contained in:
Tim Allen 2021-01-11 22:22:31 +11:00 committed by Screwtapello
parent 4f75515cd3
commit e7accf7092
2 changed files with 18 additions and 0 deletions

View File

@ -75,6 +75,11 @@ auto APU::leaf() -> void {
}
auto main() -> int {
if(!co_serializable()) {
printf("This implementation does not support serialization\n");
return 1;
}
Memory::buffer = (uint8_t*)mmap(
(void*)0x10'0000'0000, 2 * 65536,
PROT_READ | PROT_WRITE | PROT_EXEC,

View File

@ -126,6 +126,19 @@ Passing handle of active cothread to this function is not allowed.
Passing handle of primary cothread is not allowed.
## co_serializable
```c
int co_serializable(void);
```
Returns non-zero if the implementation keeps the entire coroutine state in the
buffer passed to `co_derive()`. That is, if `co_serializable()` returns
non-zero, and if your cothread does not modify the heap or any process-wide
state, then you can "snapshot" the cothread's state by taking a copy of the
buffer originally passed to `co_derive()`, and "restore" a previous state
by copying the snapshot back into the buffer it came from.
## co_switch
```c
void co_switch(cothread_t cothread);