Skip to content
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

export asyncdispatch.callSoon (fixes #7192) #9687

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/pure/asyncdispatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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().}

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions tests/async/t7192.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
discard """
output: '''
testCallback()
'''
"""

import asyncdispatch

proc testCallback() =
echo "testCallback()"

when isMainModule:
callSoon(testCallback)
poll()