Commit Graph

16 Commits

Author SHA1 Message Date
Rokas Kupstys
cd2721242a Fix waiting on coroutines (#5463)
Public coroutine API returns a safe reference to specific running coroutine. Fixes bug where multiple coroutines executing same procedure would identify as same coroutine.
Greatly optimizes `alive()` (and as a result of that `wait()`) calls.
Coroutine struct is allocated together with stack as memory unmanaged by GC.
2017-03-02 14:53:50 +01:00
Rokas Kupstys
5aef77a3d3 Removed test code from coro.nim and created three real tests for coroutines 2017-02-20 17:54:15 +02:00
Rokas Kupstys
f80ddbbcc6 Use constant nimCoroutines instead of defined(nimCoroutines)
Variable
2017-02-20 17:24:19 +02:00
Rokas Kupstys
c3d1b732d6 Reworked gc support for coroutines. Nim now bootstraps with -d:nimCoroutines
Added gc test to coro.nim
Lots of misc improvements and comments in coro.nim
2017-02-20 17:24:19 +02:00
Rokas Kupstys
ce4e9846f0 Iterators test in coroutines 2017-02-20 17:24:19 +02:00
Rokas Kupstys
ff1bf74554 Delete fiber context when it exits (memleak fix)
Few correctness changes to gc stack management.
2017-02-20 17:24:19 +02:00
Rokas Kupstys
9a754156d7 Added support for exceptions in coroutines and added exception test
Fix bug where first coroutine ending would terminate main loop
2017-02-20 17:24:19 +02:00
Rokas Kupstys
373e667dbc Coroutine rework.
* ucontext backend (default on unix)
* setjmp backend
* fibers backend (default and required on windows)
* Fixed coroutine loop timing issues
* Fixed saving of xmm registers on x64 windows
* Fixed alignment issues
* Updated coroutine sample with cooperative fibonacci calculation.
* Disable glibc security features only when platform jump functions are used
* Removed dependency on fasm.
    * Using fiber api on windows.
    * Other platforms and compilers  will use built in assembler and .S files or API provided by platform libc.
* Replaced stack switching procs with `coroExecWithStack()` which never returns. This makes compiler always generate proper code.
2017-02-20 17:24:19 +02:00
Dmitriy Fomichev
d356c37185 Workaround for the high cpu usage issue in coroutines on linux (#5186)
Fixes high cpu usage when all coroutines are asleep
2017-01-11 10:01:03 +01:00
def
41e1f3241b Fix building documentation in releases (fixes #3823) 2016-02-21 14:52:26 +01:00
Aman Gupta
b33d97621d only compile coro.nim by avoiding "when isMainModule" string match in
testament/tester

FAIL: coro.nim
Test "lib/pure/coro.nim" in category "lib"
Failure: reOutputsDiffer
Expected:

Gotten:
c1
c2
c2
c1
c2
c1
c2
c1
c1 exits
c2 exits
done 1100220033
2015-10-02 18:56:57 -07:00
Dominik Picheta
c60728326e Add :idx: for suspend in coro module. 2015-08-30 13:11:27 +01:00
Simon Hafner
24655ecd52 coro.sleep -> suspend 2015-08-30 10:24:13 +02:00
Simon Hafner
d876960b9d removed coro deprecations 2015-08-25 23:52:14 +02:00
Simon Hafner
7d9a748fcd removed coro prefixes from coro.nim 2015-08-25 16:33:44 +02:00
rku
43bfda057b Coroutine support for i386/amd64 platforms unix/windows OSes markAndSweep/refCounting GCs. 2015-07-31 17:59:50 +03:00