coro: minor documentation fix [backport] [ci skip]
This commit is contained in:
parent
37d88e5168
commit
c0b5479e6b
1 changed files with 13 additions and 11 deletions
|
|
@ -6,15 +6,17 @@
|
||||||
# See the file "copying.txt", included in this
|
# See the file "copying.txt", included in this
|
||||||
# distribution, for details about the copyright.
|
# distribution, for details about the copyright.
|
||||||
#
|
#
|
||||||
## Nim coroutines implementation supports several context switching methods:
|
## Nim coroutines implementation, supports several context switching methods:
|
||||||
## ucontext: available on unix and alike (default)
|
## -------- ------------
|
||||||
## setjmp: available on unix and alike (x86/64 only)
|
## ucontext available on unix and alike (default)
|
||||||
## Fibers: available and required on windows.
|
## setjmp available on unix and alike (x86/64 only)
|
||||||
|
## fibers available and required on windows.
|
||||||
|
## -------- ------------
|
||||||
##
|
##
|
||||||
## -d:nimCoroutines Required to build this module.
|
## -d:nimCoroutines Required to build this module.
|
||||||
## -d:nimCoroutinesUcontext Use ucontext backend.
|
## -d:nimCoroutinesUcontext Use ucontext backend.
|
||||||
## -d:nimCoroutinesSetjmp Use setjmp backend.
|
## -d:nimCoroutinesSetjmp Use setjmp backend.
|
||||||
## -d:nimCoroutinesSetjmpBundled Use bundled setjmp implementation.
|
## -d:nimCoroutinesSetjmpBundled Use bundled setjmp implementation.
|
||||||
|
|
||||||
when not nimCoroutines and not defined(nimdoc):
|
when not nimCoroutines and not defined(nimdoc):
|
||||||
when defined(noNimCoroutines):
|
when defined(noNimCoroutines):
|
||||||
|
|
@ -105,7 +107,7 @@ elif coroBackend == CORO_BACKEND_SETJMP:
|
||||||
# Use setjmp/longjmp implementation provided by the system.
|
# Use setjmp/longjmp implementation provided by the system.
|
||||||
type
|
type
|
||||||
JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = object
|
JmpBuf {.importc: "jmp_buf", header: "<setjmp.h>".} = object
|
||||||
|
|
||||||
proc setjmp(ctx: var JmpBuf): int {.importc, header: "<setjmp.h>".}
|
proc setjmp(ctx: var JmpBuf): int {.importc, header: "<setjmp.h>".}
|
||||||
proc longjmp(ctx: JmpBuf, ret=1) {.importc, header: "<setjmp.h>".}
|
proc longjmp(ctx: JmpBuf, ret=1) {.importc, header: "<setjmp.h>".}
|
||||||
|
|
||||||
|
|
@ -241,7 +243,7 @@ proc start*(c: proc(), stacksize: int=defaultStackSize): CoroutineRef {.discarda
|
||||||
## Schedule coroutine for execution. It does not run immediately.
|
## Schedule coroutine for execution. It does not run immediately.
|
||||||
if ctx == nil:
|
if ctx == nil:
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
var coro: CoroutinePtr
|
var coro: CoroutinePtr
|
||||||
when coroBackend == CORO_BACKEND_FIBERS:
|
when coroBackend == CORO_BACKEND_FIBERS:
|
||||||
coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine)))
|
coro = cast[CoroutinePtr](alloc0(sizeof(Coroutine)))
|
||||||
|
|
@ -287,7 +289,7 @@ proc run*() =
|
||||||
if current.state == CORO_FINISHED:
|
if current.state == CORO_FINISHED:
|
||||||
var next = ctx.current.prev
|
var next = ctx.current.prev
|
||||||
if next == nil:
|
if next == nil:
|
||||||
# If first coroutine ends then `prev` is nil even if more coroutines
|
# If first coroutine ends then `prev` is nil even if more coroutines
|
||||||
# are to be scheduled.
|
# are to be scheduled.
|
||||||
next = ctx.current.next
|
next = ctx.current.next
|
||||||
current.reference.coro = nil
|
current.reference.coro = nil
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue