Skip to content

Commit

Permalink
Add assertions against fibers waiting on themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
rmrfslashhome committed Dec 21, 2024
1 parent bdaf1ad commit e701ac2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sync/Context.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ Context: [{

wait: [
done? ~ [
[data.waitedBy nil?] "multiple attempts to wait on the same fiber" assert
[data.waitedBy nil? ] "multiple attempts to wait on the same fiber" assert
[data.fiber currentFiber is ~] "attempt to wait on self" assert

@currentFiber @data.!waitedBy
canceled? [
cancel
Expand Down
4 changes: 3 additions & 1 deletion sync/ContextGroup.mpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ ContextGroup: [{
] when

[fibers.empty? ~] [
[fibers.first.waitedBy nil?] "multiple attempts to wait on the same fiber" assert
[fibers.first.waitedBy nil? ] "multiple attempts to wait on the same fiber" assert
[fibers.first.fiber currentFiber is ~] "attempt to wait on self" assert

@currentFiber @fibers.@first.!waitedBy
canceled? ~ [
[currentFiber.@func @defaultCancelFunc is] "invalid cancelation function" assert
Expand Down

0 comments on commit e701ac2

Please sign in to comment.