-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New async core #4309
New async core #4309
Conversation
I have forgot, i also added isEmpty() template for ioselectors.nim, so bug #4262 is resolved in this PR. |
@@ -1680,4 +1680,4 @@ proc waitFor*[T](fut: Future[T]): T = | |||
while not fut.finished: | |||
poll() | |||
|
|||
fut.read | |||
fut.read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cheatfate what text editor are you using? Whatever it is, it's not adding a newline at the end of files which is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using SublimeText 3.
I know that @Araq asked you to put I would prefer if the features you implemented in |
Another thing, |
…t can returns ERROR_IO_PENDING.
@dom96 about |
That's a good way to do things but that's overly taxing cheatfate. He's been working on this PR for months now and afaik it's really battle-tested and has better performance than the current asyncdispatch. And yet it's compatible with the old interface! That's nothing to dismiss. More random notes:
|
I'm afraid it's not documented anywhere, but I have designed
I can continue to argue against this here (after arguing on IRC), but in the interest of time I will just say: fine, review it and merge it but don't expect me to be happy about it or to agree with the decision. |
@dom96 i dont think names is a big problem, please write here your variants of names and i can change it. |
I also think the "callback" functions should get different names. |
@dom96, so in code it will looks like: about sleepAsync(), i think the biggest problem of this function - using epochTime(), because it really slow (while converting timespec to float). And maybe its a little overhead to use hardware timer for simple Sleep. And whats wrong with |
True, in that case it doesn't look nice. But client code likely won't be using it anyway. For example, you will have a
If you would like to provide two versions of this procedure then that's fine. But give the "hardware timer" version a more descriptive name please.
Yes, but |
@dom96, please check asyncdispatch.nim code, and maybe selectors.nim code.
Just because |
Ahh. Forgot those were in there. In that case your callback functions are ok. |
@Araq, please help us with names, just because asyncdispatch.nim is a public api, so names must be nice, i think. |
IMO: asyncSleep() -> sleepAsyncHardware() |
what about timerAsync() for sleepAsyncHardware()? |
Hello. Could you add more documentation please? Need more info about new procs usage. May be more examples. |
IMHO, it would be better to merge the whole PR at once. Being author of a library that depends on async, I would prefer to fix everything at once rather than having to perform a few changes every few days as the features in ioselectors are ported to selectors slowly |
## An object which holds user defined event | ||
|
||
const | ||
EVENT_READ* = 0x00000001 ## Descriptor is available for read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless this is somehow directly mapped to the OS specific constants, this should be an enum and the combination of flags a set[myenum].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made benchmarks for simple boolean arithmetic and usage of sets
. Simple boolean arithmetic is twice as fast than sets
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt these benchmarks. What exactly did you benchmark?
part: array[16, T] | ||
SharedArray {.unchecked.}[T] = array[0..100_000_000, T] | ||
|
||
proc newSharedArray[T](nsize: int): ptr SharedArray[T] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name it allocSharedArray
.
ioselectors.nim features:
asyncdispatch.nim features:
Callback functions:
Futures:
Fully supported OS: Windows (IOCP), FreeBSD, OpenBSD, NetBSD, MacOSX, Linux.
Partially supported OS: Solaris, Windows (select)
When using Solaris or Windows only sockets and application-driven events are supported.
Changelog since v1 of this PR:
There some changes made to ioselectors.nim, so now it uses generics as application-driven data. This patch made possible to avoid some memory allocations in asyncdispatch.nim code.
TODO: Adopt Solaris
eventports
and maybe/dev/poll
in future.