Commit Graph

281 Commits

Author SHA1 Message Date
Ștefan Talpalaru baf33f04ea
asyncCheck(): don't raise exception on cancellation (#121) 2020-08-12 16:24:55 +02:00
Ștefan Talpalaru 284d677815
yieldAsync() (#120) 2020-08-10 15:31:21 +02:00
Ștefan Talpalaru d0a17d551f
more docs (#111)
* more docs

* make CancelledError and object of Exception
2020-08-06 20:52:50 +02:00
Ștefan Talpalaru e45ef32b5b
some metrics for monitoring futures (#85) 2020-08-06 19:30:53 +02: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
Eugene Kabanov 73de13ca7a
Fix SIGSEGV while consuming errors more then once. (#114) 2020-08-05 00:23:43 +03:00
Ștefan Talpalaru f5634f499d
cancelAndWait(): add comments (#112)
The cancellation process has a very complicated control flow, split over
different files and hidden by macros. These comments should help shed a
light on this madness.
2020-07-30 02:47:11 +02:00
Eugene Kabanov 31fec25063
Fix accept races. (#110)
* Fix accept races.
2020-07-15 11:09:34 +03:00
cheatfate 783f84aa4b
Fix EAGAIN issue in acceptLoop(). 2020-07-15 01:07:03 +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
Jacek Sieka f856c885fa
fix endian conversion issues (#82)
* fixes call to `bigEndian32` on a uint64 which breaks on big endian
platforms
* prefer endians2 for less and safer code
2020-07-12 18:22:47 +02:00
Ștefan Talpalaru 0ad7321aa0
ServerFlags.ReusePort support on POSIX (#95) 2020-07-12 18:13:22 +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 5629b3c41f
[WIP] Zero-cost unattended Future[T] tracking mechanism. (#106)
* Zero-cost unattended Future[T] tracking mechanism with tests and tracking of test suite.
2020-07-06 09:33:13 +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 528688d01e
Add sanity check. (#105) 2020-06-25 09:32:41 +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 02b8da986b
Add accept() call (#103)
* Add accept() call and tests.
* Fix rare fd leaks on Windows.
* Fix compilation warnings.
* Add fd leak test.
* Bump version to 2.4.0.
2020-06-24 11:21:52 +03:00
Eugene Kabanov bedd1ded5e
Properly fix cancellation race and not introduce FD leaks. (#102) 2020-06-05 19:11:51 +03:00
Eugene Kabanov d6d0084333
Fix cancellation race when connect() call is getting cancelled. (#101) 2020-06-04 13:07:52 +03:00
Kim De Mey bce0f878d1
Remove unreachable raise from initTAddress (#97) 2020-05-15 14:09:21 +03:00
Jacek Sieka aff69aaf29
fix closed error type (#99) 2020-05-13 22:45:40 +03:00
cheatfate 357baa52a0
Fix documentation for `or`. 2020-04-21 07:33:31 +03:00
Eugene Kabanov 2ecc5500c2
Undeprecate `or` operation. (#93)
* Undeprecate `or` operation.
Fix `or` for already finished futures.
Add tests.

* Bump version to 2.3.9.
2020-04-21 07:07:49 +03:00
Giovanni Petrantoni 9ea1017a06
Fix possible race condition in asyncstream close (#91) 2020-04-09 17:56:56 +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
Eugene Kabanov 4e2810cfe0
Fix issue with allFinished(), allFutures(), one() behavior when Futures passed are already finished. (#89)
Added test.
2020-04-06 13:56:24 +03:00
Eugene Kabanov cbd8e03823
Add allFinished() primitive. (#87)
* Add allCompleted() primitive.

* Rename it to allFinished().

* Fix allFinished Future's static name.
Use `mitems()` instead of `for`.
2020-04-01 12:10:56 +03:00
andri lim 72b4f14427
fix nim 1.2 compilation issue on linux 2020-03-26 16:46:31 +07:00
Araq f3827a13d1 prepare nim-chronos for Nim version 1.2 2020-03-23 20:17:29 +02:00
Jacek Sieka d8f8e3d9fc
readMsg branch by @arnetheduck with some changes. (#83)
Co-authored-by: Eugene Kabanov <ka@hardcore.kiev.ua>
2020-03-05 10:59:10 +01: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 64583b4269
Fix Windows datagram's AnyAddress issue.
Add test for datagram's AnyAddress.
Bump version to 2.3.6.
2020-02-25 23:50:39 +02:00
Zahary Karadjov a9ed7e4f3f
FutureDefect is a type of Defect 2020-02-18 00:35:03 +02:00
cheatfate 8e70d1be7a
Fix macos warnings. 2020-02-12 23:01:41 +02:00
cheatfate 80351cb928
Fix #73. 2020-02-12 22:54:05 +02:00
cheatfate 4a2416fe5e
Allow to setup datagram servers with 0 port. 2020-01-28 15:46:57 +02:00
cheatfate e34857364e
Attempt to fix #64. 2020-01-28 12:47:38 +02:00
cheatfate 74700fdcab Fix bug cancellation handlers not called in wait() and withTimeout().
Fix double completion bug because of callback race.
Fix deprecation warnings.
Rename some internal procedures.
Bump version to 2.3.5.
2020-01-27 22:32:08 +02:00
Dmitriy Ryajov 1c176c173d fix: restore `removeCallback` 2020-01-08 19:32:53 -06:00
Dmitriy Ryajov 0d84f273c9 make `clearTimer` inline 2020-01-08 11:23:01 -06:00
Dmitriy Ryajov 96e0206c27 reverting AsyncCallback to object 2020-01-08 11:06:56 -06:00
Dmitriy Ryajov 78953f8fc3 consolidating timers loop 2020-01-08 10:03:34 -06:00
Dmitriy Ryajov d8dd09a358 don't loop over timers heap 2020-01-07 19:06:27 -06:00
Dmitriy Ryajov d979770263 clear timers under windown as well 2020-01-07 10:22:38 -06:00
Dmitriy Ryajov b9c534724c don't scan timers heap on each remove 2020-01-06 23:26:18 -06:00
Dmitriy Ryajov 546cc36d79 fix: avoid completing future twise 2019-12-24 13:23:45 -06: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
Yuriy Glukhov 4d61345978
Use CatchableError as base instead of Exception 2019-11-22 18:59:02 +02:00
cheatfate 811c5f66ae
More *nix fixes. 2019-10-30 00:40:02 +02:00
cheatfate fb00b20cfa
Fix all compilation warnings for 1.0.2.
Fix all related problems.
2019-10-29 23:19:41 +02:00
cheatfate 5f1391f39f
Fix unused imports. 2019-10-24 16:21:31 +03:00
cheatfate a7ff20b299
Fix *nix compilation problem. 2019-10-24 16:06:55 +03:00
cheatfate 29d9274e03
Fix some compilation warnings. 2019-10-24 16:01:57 +03:00
cheatfate 5758d07c08
Fix compilation problems in Nim devel. 2019-10-24 15:29:21 +03:00
cheatfate b59e759e87
Fix #53 2019-10-23 14:13:23 +03:00
Yuriy Glukhov a291f26c82
Merge pull request #55 from status-im/tlsstream
TLS async stream.
2019-10-22 13:32:36 +03:00
cheatfate 368502c10b
Rename harvestItem to copyOut. 2019-10-18 19:24:58 +03:00
cheatfate 9ce7141087
Fix cancel() issue.
Fix asyncstream.nim not propagating cancellation.
Fix tlsstream.nim to proper propagate cancellation.
Fix tlsstream.nim stuck on close.
2019-10-17 14:44:14 +03:00
cheatfate d008fa2087
Fix make serverName mandatory and check for empty serverName. 2019-10-16 09:07:46 +03:00
cheatfate a92ad6d2d2
Add TLS inbound stream.
Fix some review comments.
2019-10-16 09:01:52 +03:00
cheatfate 161c50209e
Remove debugging echos. 2019-10-10 14:53:33 +03:00
cheatfate fe6fca1e67
Add hexdump.nim. 2019-10-10 13:01:14 +03:00
cheatfate 5c801a5dbc
Add upload() and some debugging. 2019-10-10 12:52:12 +03:00
cheatfate 3b8874a9e8
Fix issue with Windows connect(0.0.0.0). 2019-10-09 15:12:19 +03:00
cheatfate 3f8d529c8e
Attempt to fix state machine issue. 2019-10-09 09:12:54 +03:00
cheatfate 417111093e
Cleanup references on exit. 2019-10-08 20:38:39 +03:00
cheatfate e19101d287
Add GC reference to reader and writer. 2019-10-08 20:30:43 +03:00
cheatfate cae1d09690
Removed debugging imports. 2019-10-08 19:02:42 +03:00
cheatfate c27624cfc0
Add TlsStream with client-only connections. 2019-10-08 18:46:27 +03:00
cheatfate 3c928918a4
Change AsyncStream close procedure from events to cancellation. 2019-10-08 10:28:43 +03:00
cheatfate b0fe8398e8
Fix behavior which was agreed in #46. 2019-09-23 20:24:26 +03:00
Eugene Kabanov b41af14f86 Fix emscripten compilation errors. (#46)
* Move initAPI to newDispatcher() call.
2019-09-10 13:19:49 -04:00
cheatfate a039011f5b
Fix clock_gettime() is not available on old MacOS. 2019-09-03 17:30:28 +03:00
cheatfate 7029f8bc1e
Fix behavior for write operations. 2019-08-28 07:57:06 +03:00
Yuriy Glukhov aacfa59c76 Fixed compilation error for async lambdas 2019-08-19 20:19:26 +03:00
Eugene Kabanov 693f741c8d
Merge pull request #48 from status-im/no-Iter
No Iter in stacktraces
2019-08-16 18:14:43 +03:00
Yuriy Glukhov 2346ed3c6c Fixup error reporting 2019-08-16 15:23:51 +02:00
Bruno Škvorc bb525ace25
Fix typo in doc string
This typo was breaking nim's doc generator.
2019-08-16 12:27:27 +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 03eb8a0157
Add pipe support for StreamTransport.
Bump version to 2.2.8.
2019-07-15 12:59:42 +03:00
cheatfate ec7f2a14a8
Fix compilation warnings in osnet.nim
Fix non stable stream tests.
2019-07-12 10:40:18 +03:00
Eugene Kabanov cd2571e80a
Merge pull request #41 from status-im/cancellation
[WIP] Initial cancellation proposal.
2019-07-06 15:44:21 +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 45ca9e1184
Deprecate usage of `yield` inside of streams. 2019-07-05 13:19:04 +03:00
cheatfate fcfb87d2a0
Deprecate oneIndex(), oneValue(), all(), or(), and().
Add allFutures() and one().
Fix deprecation in chunkedstream.
Add tests.
2019-07-04 15:04:59 +03:00
cheatfate 247e453b71
Fix hidden close issue in AsyncStream. 2019-07-02 21:26:21 +03:00
cheatfate 13301005a3
Return back ValueError. 2019-06-25 10:50:56 +03:00
cheatfate 15b25140b4
Let complete/fail cancelled Future[T]/FutureVar[T] for free. 2019-06-25 10:18:47 +03:00
cheatfate 7d7753b7fd
Initial cancellation proposal. 2019-06-20 23:30:41 +03:00
cheatfate 31f4dc3096
Add ability to create copies of AsyncStreams. 2019-06-18 20:11:13 +03:00
cheatfate 5d4338d294
Fix chunkedstream documentation.
Remove unnecessary asserts.
2019-06-12 18:26:20 +03:00
cheatfate f83d1b4da4
Remove some unused symbols. 2019-06-08 08:37:58 +03:00
cheatfate a8a1138b8b
Fix for race condition in *nix connect(). 2019-06-06 21:22:17 +03:00
Eugene Kabanov 9160dcdbba
Merge pull request #37 from status-im/asyncstream
Asynchronous streams.
2019-06-06 15:05:08 +03:00
cheatfate 77b4ff0534
Remove timeout handling for streams. 2019-06-06 14:00:47 +03:00
cheatfate c27c564d47
Add oneIndex(), oneValue() which are varargs `or` operation.
Fix some deprecation warnings for Nim devel.
Add tests for oneIndex(), oneValue().
2019-06-04 19:51:35 +03:00
cheatfate 38dd4cb6e7
Fix for Nim devel discrimination checks. 2019-06-03 10:24:51 +03:00
cheatfate 49bae9792d
Fix documentation for read(n) procedure. 2019-05-28 20:12:00 +03:00
cheatfate 317ce3c797
Ignore ECONNRESET and EPIPE errors on sending.
Add test for ECONNRESET error.
2019-05-28 09:29:00 +03:00
cheatfate 2ba6e5a412
Fix ChunkedStream error to be derived from CatchableError. 2019-05-10 09:01:16 +03:00
cheatfate 939e461d04
Exceptions and handles fixes. 2019-05-10 08:27:05 +03:00
cheatfate 6e7a753793
Fix for Windows server close procedure. 2019-05-09 20:59:15 +03:00
cheatfate 454571f943
Fix tests to consume all the bytes from the nested stream.
Add error messages for nested exceptions.
2019-05-08 12:44:00 +03:00
cheatfate 1763c9dcff
Add AsyncStreams.
Add Chunked-Encoding AsyncStream reader/writer.
Add tests.
2019-05-07 23:11:40 +03:00
cheatfate bc4fa46566
Add more test vectors from `nim-libp2p`. 2019-04-15 11:30:52 +03:00
cheatfate 2c2e2f7fad
Add getInterfaces() and getBestRoute().
Add IpNet and IpMask.
Add TTL setting for UDP transports with {Broadcast}.
Fix comments.
Add tests.
Bump version to 2.2.5.
2019-04-15 04:27:12 +03:00
cheatfate 66160a9630
Move fromProc to SrcLoc. 2019-04-08 16:46:22 +03:00
cheatfate cd745a20ed
Add SourceLocation.
All the Future[T] operations using SourceLocation now.
2019-04-08 03:59:49 +03:00
cheatfate 6a1f7785a0
Custom tracking mechanism.
1. Add simple tracking of Datagram and Stream transports.
2. Fix leaks in tests.
3. Add leaks tests to Datagram and Stream transport tests.
2019-04-04 12:34:23 +03:00
cheatfate adc9035b07
Some cosmetic in Future[T] names. 2019-03-31 18:33:01 +03:00
cheatfate d3b72dbe8b
Add broadcast feature for DatagramTransport.
Add test for it.
2019-03-31 09:18:21 +03:00
cheatfate 80ee289847
Fix rarely appearing Windows bug with close(transport).
Add tests for it.
Add fromProc for all Future[T] in transports.
Add testall to improve tests speed.
Bump version to 2.2.4.
2019-03-31 00:31:10 +02:00
cheatfate 4290e06e77
Fix #16. 2019-03-29 11:53:24 +02:00
cheatfate 7d63a1b54d
Fix wait() to allow Future[void]. 2019-03-28 00:56:17 +02:00
cheatfate 51c87bf090
Fix to allow parsing of addresses with 0 port. 2019-03-27 21:42:46 +02:00
cheatfate a2b85a8126
Fix for `$`(0). 2019-03-27 07:54:41 +02:00
cheatfate 3d87707b07
Fix #21. 2019-03-26 14:29:35 +02:00
Eugene Kabanov 0ed60b8761
Merge pull request #27 from status-im/recoverable-errors
All async errors are recoverable
2019-03-26 14:02:44 +02:00
Zahary Karadjov 9d346412eb All async errors are recoverable 2019-03-26 12:29:45 +02:00
cheatfate da4709d735
Convert cast[int64] to int64, to allow usage at compile time.
Fix 32bit compilation issue.
2019-03-25 23:24:32 +02:00
cheatfate 1357045cfa
Add old version of deprecated procedures. 2019-03-24 20:59:51 +02:00
Eugene Kabanov 67e214c5df Introduce monotonic timer functions. (#24)
* Introduce monotonic timer functions.
Old fast timers are available through compiler switch.
Add tests for both timers.
* Bump version to 2.2.2.
2019-03-24 10:57:36 -06:00
cheatfate ea3fb9629a
Fixed all() implementation. 2019-03-15 02:43:51 +02:00
Ștefan Talpalaru 685665ad21
assert() -> doAssert() 2019-03-14 04:03:32 +01: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