keep the order of the callbacks
This commit is contained in:
parent
d5e113c3a6
commit
15c66a06f9
2 changed files with 14 additions and 7 deletions
|
|
@ -123,11 +123,17 @@ proc add(callbacks: var CallbackList, function: CallbackFunc) =
|
||||||
callbacks.function = function
|
callbacks.function = function
|
||||||
assert callbacks.next == nil
|
assert callbacks.next == nil
|
||||||
else:
|
else:
|
||||||
let newNext = new(ref CallbackList)
|
let newCallback = new(ref CallbackList)
|
||||||
newNext.function = callbacks.function
|
newCallback.function = function
|
||||||
newNext.next = callbacks.next
|
newCallback.next = nil
|
||||||
callbacks.next = newNext
|
|
||||||
callbacks.function = function
|
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) =
|
proc complete*[T](future: Future[T], val: T) =
|
||||||
## Completes ``future`` with value ``val``.
|
## Completes ``future`` with value ``val``.
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
discard """
|
discard """
|
||||||
exitcode: 0
|
exitcode: 0
|
||||||
output: '''3
|
output: '''
|
||||||
2
|
|
||||||
1
|
1
|
||||||
|
2
|
||||||
|
3
|
||||||
5
|
5
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue