diff options
author | Dominik Picheta <dominikpicheta@googlemail.com> | 2018-11-13 21:12:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-13 21:12:19 +0000 |
commit | 679a52f53c3b70aa6374eba7a8b5013b3aef76b8 (patch) | |
tree | 9793529c6411018a8a508a1f574b162523427de7 | |
parent | d2f7ecb80e8672f404fa59c9eb2249ffe72f5645 (diff) | |
parent | c2b16b46ecf9e62e411e5b7e6d4d861c43b1b0fe (diff) | |
download | Nim-679a52f53c3b70aa6374eba7a8b5013b3aef76b8.tar.gz |
Merge pull request #9687 from narimiran/fix-7192
export `asyncdispatch.callSoon` (fixes #7192)
-rw-r--r-- | lib/pure/asyncdispatch.nim | 7 | ||||
-rw-r--r-- | tests/async/t7192.nim | 14 |
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/pure/asyncdispatch.nim b/lib/pure/asyncdispatch.nim index 5ef791cfe..443c65f26 100644 --- a/lib/pure/asyncdispatch.nim +++ b/lib/pure/asyncdispatch.nim @@ -16,7 +16,8 @@ import asyncfutures except callSoon import nativesockets, net, deques export Port, SocketFlag -export asyncfutures, asyncstreams +export asyncfutures except callSoon +export asyncstreams #{.injectStmt: newGcInvariant().} @@ -199,7 +200,7 @@ proc adjustTimeout(pollTimeout: int, nextTimer: Option[int]): int {.inline.} = if pollTimeout == -1: return result = min(pollTimeout, result) -proc callSoon(cbproc: proc ()) {.gcsafe.} +proc callSoon*(cbproc: proc ()) {.gcsafe.} proc initCallSoonProc = if asyncfutures.getCallSoonProc().isNil: @@ -1640,7 +1641,7 @@ proc recvLine*(socket: AsyncFD): Future[string] {.async, deprecated.} = return add(result, c) -proc callSoon(cbproc: proc ()) = +proc callSoon*(cbproc: proc ()) = ## Schedule `cbproc` to be called as soon as possible. ## The callback is called when control returns to the event loop. getGlobalDispatcher().callbacks.addLast(cbproc) diff --git a/tests/async/t7192.nim b/tests/async/t7192.nim new file mode 100644 index 000000000..c380f93e1 --- /dev/null +++ b/tests/async/t7192.nim @@ -0,0 +1,14 @@ +discard """ +output: ''' +testCallback() +''' +""" + +import asyncdispatch + +proc testCallback() = + echo "testCallback()" + +when isMainModule: + callSoon(testCallback) + poll() |