You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Create a new list node for the task and add it to the list of waiting tasks:
52
54
node=TaskNode.new(task)
53
55
@tasks.append(node)
54
-
56
+
57
+
# Signal the outer async block that we have added the task to the list of waiting tasks, and that it can now wait for it to finish:
55
58
waiting=node
56
-
@cond.signal
57
-
59
+
@condition.signal
60
+
61
+
# Invoke the block, which may raise an error. If it does, we will still signal that the task has finished:
58
62
block.call(task, *arguments)
59
63
ensure
64
+
# Signal that the task has finished, which will unblock the waiting task:
60
65
@finished.signal(node)unless@finished.closed?
61
66
end
62
-
63
-
@cond.waitwhilewaiting.nil?
64
-
65
-
task
67
+
68
+
# `parent.async` may yield before the child block executes, so we wait here until the child has appended itself to `@tasks`, ensuring `wait` cannot return early and miss tracking it:
69
+
@condition.waitwhilewaiting.nil?
70
+
71
+
returntask
66
72
end
67
73
68
74
# Whether there are any tasks being held by the barrier.
0 commit comments