Commit Graph

27 Commits

Author SHA1 Message Date
Jacek Sieka 895fc53193
add explicit gcsafe annotations (fixes #174) (#175)
Seems like a variation of https://github.com/nim-lang/Nim/issues/17369
2021-04-03 10:05:08 +02:00
markspanbroek e5d3ecdd01
Ensures that asyncmacro2 does not raise exceptions (#172)
* Ensures that asyncmacro2 does not raise exceptions

* Remove unnecessary include
2021-03-30 16:48:20 +02:00
Jacek Sieka 075b7abf4c
fix Defect check in non-strict mode (#170) 2021-03-25 15:53:33 +01:00
Jacek Sieka 4abd7a5645
exception tracking (#166)
* exception tracking

This PR adds minimal exception tracking to chronos, moving the goalpost
one step further.

In particular, it becomes invalid to raise exceptions from `callSoon`
callbacks: this is critical for writing correct error handling because
there's no reasonable way that a user of chronos can possibly _reason_
about exceptions coming out of there: the event loop will be in an
indeterminite state when the loop is executing an _random_ callback.

As expected, there are several issues in the error handling of chronos:
in particular, it will end up in an inconsistent internal state whenever
the selector loop operations fail, because the internal state update
functions are not written in an exception-safe way. This PR turns this
into a Defect, which probably is not the optimal way of handling things
- expect more work to be done here.

Some API have no way of reporting back errors to callers - for example,
when something fails in the accept loop, there's not much it can do, and
no way to report it back to the user of the API - this has been fixed
with the new accept flow - the old one should be deprecated.

Finally, there is information loss in the API: in composite operations
like `poll` and `waitFor` there's no way to differentiate internal
errors from user-level errors originating from callbacks.

* store `CatchableError` in future
* annotate proc's with correct raises information
* `selectors2` to avoid non-CatchableError IOSelectorsException
* `$` should never raise
* remove unnecessary gcsafe annotations
* fix exceptions leaking out of timer waits
* fix some imports
* functions must signal raising the union of all exceptions across all
platforms to enable cross-platform code
* switch to unittest2
* add `selectors2` which supercedes the std library version and fixes
several exception handling issues in there

* fixes

* docs, platform-independent eh specifiers for some functions

* add feature flag for strict exception mode

also bump version to 3.0.0 - _most_ existing code should be compatible
with this version of exception handling but some things might need
fixing - callbacks, existing raises specifications etc.

* fix AsyncCheck for non-void T
2021-03-24 10:08:33 +01:00
Jacek Sieka 483054cda6
small fixes (#127)
* small fixes

* more efficient codegen for nil check (much less code)
* release futures earlier in AsyncEvent
* release finished future earlier in AsyncQueue
* avoid searches for futures (deque variant unused / broken)
* avoid catching defects

* Fix AsyncEvent test, because of optimization.

* delete fix

* avoid seq allocs

* Keep style consistent with other code.
Refactor AsyncEvent and AsyncQueue to not use `result` keyword.

Co-authored-by: cheatfate <eugene.kabanov@status.im>
2020-09-10 11:39:10 +03:00
Eugene Kabanov 126ea4bc56
Fix newFuture[T] location source for generated async procedures. (#125)
Add tests to for locations.
2020-09-03 14:37:53 +03:00
zah 0d4d0002b0
Produce an error when the result variable is used in void async procs (#117) 2020-08-05 16:28:11 +03:00
Ștefan Talpalaru 63041b2d8f
start documenting the library (#109)
* start documenting the library

* introduce futures

* running the event loop

* async procs and "await"

* more "await" examples

* clarify internal callback creation

* error handling

* address review comments

* remove TODO item

* more about future completion
2020-07-13 17:59:11 +02:00
Eugene Kabanov ce6e7d17b1
Make Future tracking and stack traces optional (#108)
* Make Future tracking optional via -d:chronosDutureTracking compilation flag.
* Stack traces is now optional, use -d:chronosStackTraces.
* Fix mistypes and add test for chronosStackTrace option.
2020-07-08 19:48:01 +03:00
Eugene Kabanov 16ed169f25
Fix cancellation race when low level futures are already completed, while cancellation process is pending. (#107)
Added test.
2020-07-03 15:03:59 +03:00
Eugene Kabanov 319e2bfc09
Fix Nim's issue #13899 using #14723 and add tests. (#104) 2020-06-24 13:03:36 +03:00
Eugene Kabanov 3d745a4b0c
Fix Nim's issue #13889 https://github.com/nim-lang/Nim/issues/13889. (#90) 2020-04-06 15:49:09 +03:00
Araq f3827a13d1 prepare nim-chronos for Nim version 1.2 2020-03-23 20:17:29 +02:00
cheatfate 56fbdff096
Async transformed procedures will not catch Exception anymore.
Bump version to 2.3.7.
2020-03-03 13:42:43 +02:00
cheatfate a20c34603e
Revert back some exception changes. 2019-12-02 12:40:41 +02:00
cheatfate 73c130abb4
Remove usage of getCurrentException().
Bump version to 2.3.4.
2019-11-28 20:14:19 +02:00
Eugene Kabanov b41af14f86 Fix emscripten compilation errors. (#46)
* Move initAPI to newDispatcher() call.
2019-09-10 13:19:49 -04:00
Yuriy Glukhov aacfa59c76 Fixed compilation error for async lambdas 2019-08-19 20:19:26 +03:00
Yuriy Glukhov 2346ed3c6c Fixup error reporting 2019-08-16 15:23:51 +02:00
Yuriy Glukhov bff83a9c3c Disallow waitFor in async 2019-08-15 17:41:15 +02:00
Yuriy Glukhov a30e4fe361 No Iter in stacktraces 2019-08-15 17:26:00 +02:00
Yuriy Glukhov e3cb0d1a96 Await is a template now 2019-08-15 16:01:26 +02:00
cheatfate 45f15ca6d7
Fix asyncmacro bug which introduces problems after cancellation got supported. 2019-07-19 13:06:32 +03:00
cheatfate c4a99447bd
Fix AsyncLock race and refactor asyncsync.nim to properly support cancellation.
Fix async macro to not transform nested procedures.
2019-07-17 16:12:31 +03:00
cheatfate 8ba4fc9876
Add `awaitne` command which will have `yield` behavior in async cancellation world.
Add tests for both `await` and `awaitne`.
2019-07-06 11:16:31 +03:00
cheatfate 7d7753b7fd
Initial cancellation proposal. 2019-06-20 23:30:41 +03:00
Mamy Ratsimbazafy 9f15c6b752
Rebrand Asyncdispatch2 to Chronos [WIP] (#20)
* Update file headers, copyright date

* Rename files and hopefully fix nimble

* Forgot to change path in tests

* Update readme
2019-02-06 15:49:11 +01:00