Merge pull request #9642 from narimiran/callback-order

keep the order of the callbacks
This commit is contained in:
Dominik Picheta
2018-11-07 23:46:29 +00:00
committed by GitHub
2 changed files with 14 additions and 7 deletions

View File

@@ -123,11 +123,17 @@ proc add(callbacks: var CallbackList, function: CallbackFunc) =
callbacks.function = function
assert callbacks.next == nil
else:
let newNext = new(ref CallbackList)
newNext.function = callbacks.function
newNext.next = callbacks.next
callbacks.next = newNext
callbacks.function = function
let newCallback = new(ref CallbackList)
newCallback.function = function
newCallback.next = nil
if callbacks.next == nil:
callbacks.next = newCallback
else:
var last = callbacks.next
while last.next != nil:
last = last.next
last.next = newCallback
proc complete*[T](future: Future[T], val: T) =
## Completes ``future`` with value ``val``.

View File

@@ -1,8 +1,9 @@
discard """
exitcode: 0
output: '''3
2
output: '''
1
2
3
5
'''
"""