From 9f15c6b7528de313e3d8b3a1fecd81f66998ab20 Mon Sep 17 00:00:00 2001 From: Mamy Ratsimbazafy Date: Wed, 6 Feb 2019 15:49:11 +0100 Subject: [PATCH] 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 --- LICENSE-APACHEv2 | 2 +- LICENSE-MIT | 2 +- README.md | 14 +++++++------- asyncdispatch2.nim => chronos.nim | 6 +++--- asyncdispatch2.nimble => chronos.nimble | 10 ++++++---- {asyncdispatch2 => chronos}/asyncfutures2.nim | 6 +++--- {asyncdispatch2 => chronos}/asyncloop.nim | 6 +++--- {asyncdispatch2 => chronos}/asyncmacro2.nim | 0 {asyncdispatch2 => chronos}/asyncsync.nim | 10 +++++----- {asyncdispatch2 => chronos}/handles.nim | 4 ++-- {asyncdispatch2 => chronos}/sendfile.nim | 4 ++-- {asyncdispatch2 => chronos}/timer.nim | 6 +++--- {asyncdispatch2 => chronos}/transport.nim | 4 ++-- {asyncdispatch2 => chronos}/transports/common.nim | 8 ++++---- .../transports/datagram.nim | 4 ++-- {asyncdispatch2 => chronos}/transports/stream.nim | 4 ++-- tests/testaddress.nim | 6 +++--- tests/testbugs.nim | 6 +++--- tests/testdatagram.nim | 6 +++--- tests/testfut.nim | 6 +++--- tests/testserver.nim | 6 +++--- tests/testsignal.nim | 6 +++--- tests/testsoon.nim | 6 +++--- tests/teststream.nim | 6 +++--- tests/testsync.nim | 6 +++--- tests/testtime.nim | 6 +++--- 26 files changed, 76 insertions(+), 74 deletions(-) rename asyncdispatch2.nim => chronos.nim (64%) rename asyncdispatch2.nimble => chronos.nimble (77%) rename {asyncdispatch2 => chronos}/asyncfutures2.nim (99%) rename {asyncdispatch2 => chronos}/asyncloop.nim (99%) rename {asyncdispatch2 => chronos}/asyncmacro2.nim (100%) rename {asyncdispatch2 => chronos}/asyncsync.nim (98%) rename {asyncdispatch2 => chronos}/handles.nim (97%) rename {asyncdispatch2 => chronos}/sendfile.nim (98%) rename {asyncdispatch2 => chronos}/timer.nim (90%) rename {asyncdispatch2 => chronos}/transport.nim (76%) rename {asyncdispatch2 => chronos}/transports/common.nim (99%) rename {asyncdispatch2 => chronos}/transports/datagram.nim (99%) rename {asyncdispatch2 => chronos}/transports/stream.nim (99%) diff --git a/LICENSE-APACHEv2 b/LICENSE-APACHEv2 index 782d1bf..4c352ea 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 8766e65..0e874d5 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 cc65efa..5caace8 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 d46ad15..3294631 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 86fbe6e..32844de 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 28f96cd..c88e568 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 b1d487b..e79f74b 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 3faf4b0..ba3813b 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 84c1c7c..9d22887 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 e6c38a2..670e79b 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 a236c6a..8410504 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 0394bc1..5602a8a 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 7190354..44f407a 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 9d6bd18..f983a2d 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 2f8a82f..1dd81e3 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 9e9dbf4..c92b66e 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 dedd0a4..58fc129 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 2ce4dfb..f2b7997 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 c96b8be..7497a96 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 0e058ff..39be51d 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 196223d..05b912a 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 115f459..488ae3f 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 198b0fb..3c2c349 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 cb0538f..f4816aa 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 224a1c6..c83b1a2 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