Merge pull request #9642 from narimiran/callback-order
keep the order of the callbacks
This commit is contained in:
commit
d0a02fe66b
2 changed files with 14 additions and 7 deletions
|
|
@ -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``.
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
discard """
|
||||
exitcode: 0
|
||||
output: '''3
|
||||
2
|
||||
output: '''
|
||||
1
|
||||
2
|
||||
3
|
||||
5
|
||||
'''
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue