diff --git a/LICENSE-APACHEv2 b/LICENSE-APACHEv2 index 782d1bff..4c352ea7 100644 --- a/LICENSE-APACHEv2 +++ b/LICENSE-APACHEv2 @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2018 Status Research & Development GmbH + Copyright 2018-Present Status Research & Development GmbH Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/LICENSE-MIT b/LICENSE-MIT index 8766e65d..0e874d55 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2018 Status Research & Development GmbH +Copyright (c) 2018-Present Status Research & Development GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index cc65efa9..5caace8e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Asyncdispatch hard fork +# Chronos - The Efficient Asynchronous library [![Build Status (Travis)](https://img.shields.io/travis/status-im/nim-asyncdispatch2/master.svg?label=Linux%20/%20macOS "Linux/macOS build status (Travis)")](https://travis-ci.org/status-im/nim-asyncdispatch2) [![Windows build status (Appveyor)](https://img.shields.io/appveyor/ci/nimbus/nim-asyncdispatch2/master.svg?label=Windows "Windows build status (Appveyor)")](https://ci.appveyor.com/project/nimbus/nim-asyncdispatch2) [![License: Apache](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![Stability: experimental](https://img.shields.io/badge/stability-experimental-orange.svg) -## Core differences between asyncdispatch and asyncdispatch2 +## Core differences between the standard library asyncdispatch and Chronos 1. Unified callback type `CallbackFunc`: @@ -40,7 +40,7 @@ 3. Changed the behavior of OS descriptor event callbacks: - For some unknown reason, the current version of asyncdispatch uses seq[T] to hold a list of descriptor event listeners. However, in the asynchronous environment, there is no need for a list of event listeners. In asyncdispatch2, there is only one place for one READ listener and one place for one WRITE listener. + For some unknown reason, the current version of asyncdispatch uses seq[T] to hold a list of descriptor event listeners. However, in the asynchronous environment, there is no need for a list of event listeners. In Chronos, there is only one place for one READ listener and one place for one WRITE listener. 4. Removed the default timeout value for the poll() procedure, which allows incorrect usage of asyncdispatch and produces 500-ms timeouts in correct usage. @@ -53,7 +53,7 @@ * https://github.com/nim-lang/Nim/issues/6929 -6. Asyncdispatch2 no longer uses `epochTime()`; instead, it uses the fastest time primitives for a specific OS, `fastEpochTime()`. Also, because MacOS supports only a millisecond resolution in `kqueue`, sub-millisecond resolution is not needed. For details, see https://github.com/nim-lang/Nim/issues/3909. +6. Chronos no longer uses `epochTime()`; instead, it uses the fastest time primitives for a specific OS, `fastEpochTime()`. Also, because MacOS supports only a millisecond resolution in `kqueue`, sub-millisecond resolution is not needed. For details, see https://github.com/nim-lang/Nim/issues/3909. 7. Removed all IO primitives (`recv()`, `recvFrom()`, `connect()`, `accept()`, `send()`, and `sendTo()`) from the public API, and moved all their functionality into Transports. @@ -70,13 +70,13 @@ 13. Added cheap synchronization primitives: `AsyncLock`, `AsyncEvent`, and `AsyncQueue[T]`. ## Documentation -You can find more documentation, notes and examples in [Wiki](https://github.com/status-im/nim-asyncdispatch2/wiki). +You can find more documentation, notes and examples in [Wiki](https://github.com/status-im/nim-chronos/wiki). ## Installation -You can use Nim official package manager `nimble` to install `asyncdispatch2`. The most recent version of the library can be installed via: +You can use Nim official package manager `nimble` to install `chronos`. The most recent version of the library can be installed via: ``` -$ nimble install https://github.com/status-im/nim-asyncdispatch2.git +$ nimble install https://github.com/status-im/nim-chronos.git ``` ## TODO diff --git a/asyncdispatch2.nim b/chronos.nim similarity index 64% rename from asyncdispatch2.nim rename to chronos.nim index d46ad15d..3294631c 100644 --- a/asyncdispatch2.nim +++ b/chronos.nim @@ -1,11 +1,11 @@ -# Asyncdispatch2 -# (c) Copyright 2018 +# Chronos +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) # MIT license (LICENSE-MIT) -import asyncdispatch2/[asyncloop, asyncfutures2, asyncsync, handles, transport, +import chronos/[asyncloop, asyncfutures2, asyncsync, handles, transport, timer] export asyncloop, asyncfutures2, asyncsync, handles, transport, timer diff --git a/asyncdispatch2.nimble b/chronos.nimble similarity index 77% rename from asyncdispatch2.nimble rename to chronos.nimble index 86fbe6e8..32844deb 100644 --- a/asyncdispatch2.nimble +++ b/chronos.nimble @@ -1,9 +1,11 @@ -packageName = "asyncdispatch2" -version = "2.1.6" +packageName = "chronos" +version = "2.2.0" author = "Status Research & Development GmbH" -description = "Asyncdispatch2" +description = "Chronos" license = "Apache License 2.0 or MIT" -skipDirs = @["tests", "Nim", "nim", "benchmarks"] +# workaround while chronos is still named asyncdispatch2 in Nimble +srcDir = "chronos" +# skipDirs = @["tests"] ### Dependencies diff --git a/asyncdispatch2/asyncfutures2.nim b/chronos/asyncfutures2.nim similarity index 99% rename from asyncdispatch2/asyncfutures2.nim rename to chronos/asyncfutures2.nim index 28f96cdd..c88e568b 100644 --- a/asyncdispatch2/asyncfutures2.nim +++ b/chronos/asyncfutures2.nim @@ -1,8 +1,8 @@ # -# Asyncdispatch2 +# Chronos # -# (c) Coprygith 2015 Dominik Picheta -# (c) Copyright 2018 Status Research & Development GmbH +# (c) Copyright 2015 Dominik Picheta +# (c) Copyright 2018-Present Status Research & Development GmbH # # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) diff --git a/asyncdispatch2/asyncloop.nim b/chronos/asyncloop.nim similarity index 99% rename from asyncdispatch2/asyncloop.nim rename to chronos/asyncloop.nim index b1d487b7..e79f74be 100644 --- a/asyncdispatch2/asyncloop.nim +++ b/chronos/asyncloop.nim @@ -1,8 +1,8 @@ # -# Asyncdispatch2 +# Chronos # -# (c) Coprygith 2015 Dominik Picheta -# (c) Copyright 2018 Status Research & Development GmbH +# (c) Copyright 2015 Dominik Picheta +# (c) Copyright 2018-Present Status Research & Development GmbH # # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) diff --git a/asyncdispatch2/asyncmacro2.nim b/chronos/asyncmacro2.nim similarity index 100% rename from asyncdispatch2/asyncmacro2.nim rename to chronos/asyncmacro2.nim diff --git a/asyncdispatch2/asyncsync.nim b/chronos/asyncsync.nim similarity index 98% rename from asyncdispatch2/asyncsync.nim rename to chronos/asyncsync.nim index 3faf4b07..ba3813b6 100644 --- a/asyncdispatch2/asyncsync.nim +++ b/chronos/asyncsync.nim @@ -1,8 +1,8 @@ # -# Asyncdispatch2 synchronization primitives +# Chronos synchronization primitives # -# (c) Coprygith 2018 Eugene Kabanov -# (c) Copyright 2018 Status Research & Development GmbH +# (c) Copyright 2018-Present Eugene Kabanov +# (c) Copyright 2018-Present Status Research & Development GmbH # # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) @@ -219,7 +219,7 @@ proc addLastNoWait*[T](aq: AsyncQueue[T], item: T) = proc popFirstNoWait*[T](aq: AsyncQueue[T]): T = ## Get an item from the beginning of the queue ``aq`` immediately. - ## + ## ## If queue ``aq`` is empty, then ``AsyncQueueEmptyError`` exception raised. var w: Future[void] if aq.empty(): @@ -231,7 +231,7 @@ proc popFirstNoWait*[T](aq: AsyncQueue[T]): T = proc popLastNoWait*[T](aq: AsyncQueue[T]): T = ## Get an item from the end of the queue ``aq`` immediately. - ## + ## ## If queue ``aq`` is empty, then ``AsyncQueueEmptyError`` exception raised. var w: Future[void] if aq.empty(): diff --git a/asyncdispatch2/handles.nim b/chronos/handles.nim similarity index 97% rename from asyncdispatch2/handles.nim rename to chronos/handles.nim index 84c1c7c9..9d228875 100644 --- a/asyncdispatch2/handles.nim +++ b/chronos/handles.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 Handles -# (c) Copyright 2018 +# Chronos Handles +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of diff --git a/asyncdispatch2/sendfile.nim b/chronos/sendfile.nim similarity index 98% rename from asyncdispatch2/sendfile.nim rename to chronos/sendfile.nim index e6c38a2d..670e79bb 100644 --- a/asyncdispatch2/sendfile.nim +++ b/chronos/sendfile.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 SendFile -# (c) Copyright 2018 +# Chronos SendFile +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of diff --git a/asyncdispatch2/timer.nim b/chronos/timer.nim similarity index 90% rename from asyncdispatch2/timer.nim rename to chronos/timer.nim index a236c6ab..84105049 100644 --- a/asyncdispatch2/timer.nim +++ b/chronos/timer.nim @@ -1,8 +1,8 @@ # -# Asyncdispatch2 Timer +# Chronos Timer # -# (c) Coprygith 2017 Eugene Kabanov -# (c) Copyright 2018 Status Research & Development GmbH +# (c) Copyright 2017 Eugene Kabanov +# (c) Copyright 2018-Present Status Research & Development GmbH # # Licensed under either of # Apache License, version 2.0, (LICENSE-APACHEv2) diff --git a/asyncdispatch2/transport.nim b/chronos/transport.nim similarity index 76% rename from asyncdispatch2/transport.nim rename to chronos/transport.nim index 0394bc13..5602a8aa 100644 --- a/asyncdispatch2/transport.nim +++ b/chronos/transport.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 Transport -# (c) Copyright 2018 +# Chronos Transport +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of diff --git a/asyncdispatch2/transports/common.nim b/chronos/transports/common.nim similarity index 99% rename from asyncdispatch2/transports/common.nim rename to chronos/transports/common.nim index 71903542..44f407af 100644 --- a/asyncdispatch2/transports/common.nim +++ b/chronos/transports/common.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 Transport Common Types -# (c) Copyright 2018 +# Chronos Transport Common Types +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -352,7 +352,7 @@ proc toSAddr*(address: TransportAddress, sa: var Sockaddr_storage, proc address*(ta: TransportAddress): IpAddress = ## Converts ``TransportAddress`` to ``net.IpAddress`` object. - ## + ## ## Note its impossible to convert ``TransportAddress`` of ``Unix`` family, ## because ``IpAddress`` supports only IPv4, IPv6 addresses. if ta.family == AddressFamily.IPv4: @@ -453,7 +453,7 @@ proc resolveTAddress*(address: string, port: Port, if family == IpAddressFamily.IPv4: result = resolveTAddress(address, port, AddressFamily.IPv4) elif family == IpAddressFamily.IPv6: - result = resolveTAddress(address, port, AddressFamily.IPv6) + result = resolveTAddress(address, port, AddressFamily.IPv6) template checkClosed*(t: untyped) = if (ReadClosed in (t).state) or (WriteClosed in (t).state): diff --git a/asyncdispatch2/transports/datagram.nim b/chronos/transports/datagram.nim similarity index 99% rename from asyncdispatch2/transports/datagram.nim rename to chronos/transports/datagram.nim index 9d6bd18c..f983a2d8 100644 --- a/asyncdispatch2/transports/datagram.nim +++ b/chronos/transports/datagram.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 Datagram Transport -# (c) Copyright 2018 +# Chronos Datagram Transport +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of diff --git a/asyncdispatch2/transports/stream.nim b/chronos/transports/stream.nim similarity index 99% rename from asyncdispatch2/transports/stream.nim rename to chronos/transports/stream.nim index 2f8a82fd..1dd81e36 100644 --- a/asyncdispatch2/transports/stream.nim +++ b/chronos/transports/stream.nim @@ -1,6 +1,6 @@ # -# Asyncdispatch2 Stream Transport -# (c) Copyright 2018 +# Chronos Stream Transport +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of diff --git a/tests/testaddress.nim b/tests/testaddress.nim index 9e9dbf49..c92b66e1 100644 --- a/tests/testaddress.nim +++ b/tests/testaddress.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import strutils, unittest -import ../asyncdispatch2 +import ../chronos when isMainModule: suite "TransportAddress test suite": diff --git a/tests/testbugs.nim b/tests/testbugs.nim index dedd0a48..58fc129b 100644 --- a/tests/testbugs.nim +++ b/tests/testbugs.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest -import ../asyncdispatch2 +import ../chronos const HELLO_PORT = 45679 const TEST_MSG = "testmsg" diff --git a/tests/testdatagram.nim b/tests/testdatagram.nim index 2ce4dfb7..f2b7997f 100644 --- a/tests/testdatagram.nim +++ b/tests/testdatagram.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import strutils, net, unittest -import ../asyncdispatch2 +import ../chronos const TestsCount = 2000 diff --git a/tests/testfut.nim b/tests/testfut.nim index c96b8be0..7497a961 100644 --- a/tests/testfut.nim +++ b/tests/testfut.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest -import ../asyncdispatch2 +import ../chronos proc testFuture1(): Future[int] {.async.} = await sleepAsync(100) diff --git a/tests/testserver.nim b/tests/testserver.nim index 0e058ffb..39be51d6 100644 --- a/tests/testserver.nim +++ b/tests/testserver.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import strutils, unittest -import ../asyncdispatch2 +import ../chronos type CustomServer = ref object of StreamServer diff --git a/tests/testsignal.nim b/tests/testsignal.nim index 196223d9..05b912af 100644 --- a/tests/testsignal.nim +++ b/tests/testsignal.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest, strutils -import ../asyncdispatch2 +import ../chronos when not defined(windows): import posix diff --git a/tests/testsoon.nim b/tests/testsoon.nim index 115f4591..488ae3f3 100644 --- a/tests/testsoon.nim +++ b/tests/testsoon.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest -import ../asyncdispatch2 +import ../chronos const CallSoonTests = 10 var soonTest1 = 0'u diff --git a/tests/teststream.nim b/tests/teststream.nim index 198b0fb4..3c2c3490 100644 --- a/tests/teststream.nim +++ b/tests/teststream.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import strutils, unittest, os -import ../asyncdispatch2 +import ../chronos when defined(windows): import winlean diff --git a/tests/testsync.nim b/tests/testsync.nim index cb0538f1..f4816aaf 100644 --- a/tests/testsync.nim +++ b/tests/testsync.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest -import ../asyncdispatch2 +import ../chronos var testLockResult = "" var testEventResult = "" diff --git a/tests/testtime.nim b/tests/testtime.nim index 224a1c61..c83b1a25 100644 --- a/tests/testtime.nim +++ b/tests/testtime.nim @@ -1,5 +1,5 @@ -# Asyncdispatch2 Test Suite -# (c) Copyright 2018 +# Chronos Test Suite +# (c) Copyright 2018-Present # Status Research & Development GmbH # # Licensed under either of @@ -7,7 +7,7 @@ # MIT license (LICENSE-MIT) import unittest -import ../asyncdispatch2, ../asyncdispatch2/timer +import ../chronos, ../chronos/timer const TimersCount = 10