Feature flags allow consumers of chronos to target versions with and
without certain features via compile-time selection. The first feature
flag added is for raise tracking support.
This avoids copies here and there throughout the pipeline - ie
`copyString` and friends can often be avoided when moving things into
and out of futures
Annoyingly, one has to sprinkle the codebase liberally with `sink` and
`move` for the pipeline to work well - sink stuff _generally_ works
better in orc/arc
Looking at nim 1.6/refc, sink + local variable + move generates the best
code:
msg directly:
```nim
T1_ = (*colonenv_).msg1; (*colonenv_).msg1 = copyStringRC1(msg);
```
local copy without move:
```nim
T60_ = (*colonenv_).localCopy1; (*colonenv_).localCopy1 =
copyStringRC1(msg);
```
local copy with move:
```nim
asgnRef((void**) (&(*colonenv_).localCopy1), msg);
```
Annoyingly, sink is also broken for refc+literals as it tries to
changes the refcount of the literal as part of the move (which shouldn't
be happening, but here we are), so we have to use a hack to find
literals and avoid moving them.
This PR replaces the global strict exception mode with an option to
handle `Exception` per function while at the same time enabling strict
exception checking globally by default as has been planned for v4.
`handleException` mode raises `AsyncExceptionError` to distinguish it
from `ValueError` which may originate from user code.
* remove obsolete 1.2 config options
* move `Future[T]` into its own module along with some basic accessors
* mark all fields internal, exposing only read-only versions under the
old names
* introduce `init`/`completed`/etc as a way of creating a future (vs
newFuture)
* introduce `LocationKind` for `SrcLoc` access
* don't expose `FutureList` unless future tracking is enabled
* introduce `chronosStrictFutureAccess` which controls a number of
additional `Defect` being raised when accessing Future fields in the
wrong state - this will become true in a future version
In this version, `Future[T]` backwards compatibility code remains in
`asyncfutures2` meaning that if only `chronos/futures` is imported, only
"new" API is available.
This branch is a refinement / less invasive / minimal version of
https://github.com/status-im/nim-chronos/pull/373.
* Initial commit.
* Some Linux fixes.
* Address review comments on Windows.
* Fix issues on Linux.
* Fix 1.2 issue and Windows warnings.
* Fix posix compilation issues.
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.