keep the order of the callbacks

This commit is contained in:
narimiran
2018-11-07 15:22:02 +01:00
parent d5e113c3a6
commit 15c66a06f9
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
'''
"""