* add missing calls to await
* add test run in v3 compatibility
* fix semantics for chronosHandleException so it does not override local raises/handleException annotations
* distinguish between explicit override and default setting; fix test
* re-enable wrongly disabled check
* make implementation simpler/clearer
* update docs
* reflow long line
* word swap
Features:
* Exception effects / raises for async procedures helping you write more
efficient leak-free code
* Cross-thread notification mechanism for suitable building channels,
queues and other multithreaded primitives
* Async process I/O
* IPv6 dual stack support
* HTTP middleware support alloing multiple services to share a single
http server
* A new [documentation web
site](https://status-im.github.io/nim-chronos/) covering the basics,
with several simple examples for getting started
* Implicit returns, support for `results.?` and other conveniences
* Rate limiter
* Revamped cancellation support with more control over the cancellation
process
* Efficiency improvements with `lent` and `sink`
See the [porting](https://status-im.github.io/nim-chronos/porting.html)
guides for porting code from earlier chronos releases (as well as
asyncdispatch)
* introduce user guide based on `mdbook`
* set up structure for adding simple `chronos` usage examples
* move most readme content to book
* ci deploys book and api guide automatically
* remove most of existing engine docs (obsolete)
* Exception tracking v2
* some fixes
* Nim 1.2 compat
* simpler things
* Fixes for libp2p
* Fixes for strictException
* better await exception check
* Fix for template async proc
* make async work with procTy
* FuturEx is now a ref object type
* add tests
* update test
* update readme
* Switch to asyncraises pragma
* Address tests review comments
* Rename FuturEx to RaiseTrackingFuture
* Fix typo
* Split asyncraises into async, asyncraises
* Add -d:chronosWarnMissingRaises
* Add comment to RaiseTrackingFuture
* Allow standalone asyncraises
* CheckedFuture.fail type checking
* First cleanup
* Remove useless line
* Review comments
* nimble: Remove #head from unittest2
* Remove implict raises: CancelledError
* Move checkFutureExceptions to asyncfutures2
* Small refacto
* small cleanup
* Complete in closure finally
* cleanup tests, add comment
* bump
* chronos is not compatible with nim 1.2 anymore
* re-add readme modifications
* fix special exception handlers
* also propagate excetion type in `read`
* `RaiseTrackingFuture` -> `InternalRaisesFuture`
Use internal naming scheme for RTF (this type should only be accessed
via asyncraises)
* use `internalError` for error reading
* oops
* 2.0 workarounds
* again
* remove try/finally for non-raising functions
* Revert "remove try/finally for non-raising functions"
This reverts commit 86bfeb5c97.
`finally` is needed if code returns early :/
* fixes
* avoid exposing `newInternalRaisesFuture` in manual macro code
* avoid unnecessary codegen for `Future[void]`
* avoid reduntant block around async proc body
* simplify body generation for forward declarations with comment but no
body
* avoid duplicate `gcsafe` annotiations
* line info for return at end of async proc
* expand tests
* fix comments, add defer test
---------
Co-authored-by: Jacek Sieka <jacek@status.im>
This PR moves all compile-time configuration to a single module,
simplifying documentation and access to these features.
Upcomfing features may be enabled either individually, or through a new
`chronosPreviewV4` catch-all designed to allow code to be prepared for
increased strictness in future chronos releases.
`-d:chronosDebug` may be used to enable the existing debugging helpers
together.
* ioselectors_epoll() refactoring.
* ioselectors_kqueue() refactoring.
* ioselectors_poll() initial refactor.
* Remove `s.count` because it inconsistent and not used in `chronos`.
* Remove Windows version of select() engine.
* Add ability to switch event queue engine via `asyncEventEngine` command line option.
* Make it possible to switch between engines.
* Fix epoll regression.
* Fix poll() engine issues.
* Address review comments.
* Add proper trick.
* Address review comments.
* Bump version to 3.1.0.
When `write` is called on a `StreamTransport`, the current sequence of
operations is:
* copy data to queue
* register for "write" event notification
* return unfinished future to `write` caller
* wait for "write" notification (in `poll`)
* perform one `send`
* wait for notification again if there's more data to write
* complete the future
In this PR, we introduce a fast path for writing:
* If the queue is empty, try to send as much data as possible
* If all data is sent, return completed future without `poll` round
* If there's more data to send than can be sent in one go, add the
rest to queue
* If the queue is not empty, enqueue as above
* When notified that write is possible, keep writing until OS buffer is
full before waiting for event again
The fast path provides significant performance benefits when there are
many small writes, such as when sending gossip to many peers, by
avoiding the poll loop and data copy on each send.
Also fixes an issue where the socket would not be removed from the
writer set if there were pending writes on close.
* Refactor common.nim to remove `result` usage.
Fix comparison of TransportAddress issue.
Add resolveTAddress procedures for both IPv4 and IPv6 addresses.
Fix tests.
* Bump version to 3.0.2.
* 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
This reverts commit e45ef32b5b.
Metrics implemented this way, with a lock inside the otherwise tight
event loop are not consistent with the chronos architecture that for
good or bad uses thread local variables to avoid them - the solution
does not have rough consensus behind it, and other avenues should be
explored for this generally useful functionality.