mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
Merge pull request #9642 from narimiran/callback-order
keep the order of the callbacks
This commit is contained in:
@@ -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
|
||||
'''
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user