Skip to content

Commit 539d1e2

Browse files
committed
Don't automatically initialize Cancellable.group to Unlinked
Resolves infinite initialization loop. We need to check for its nullness when doing a re-link.
1 parent 8c61b02 commit 539d1e2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

shared/src/main/scala/async/Cancellable.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ package gears.async
33
/** A trait for cancellable entities that can be grouped. */
44
trait Cancellable:
55

6-
private var group: CompletionGroup = CompletionGroup.Unlinked
6+
private var group: CompletionGroup = scala.compiletime.uninitialized
77

88
/** Issue a cancel request */
99
def cancel(): Unit
1010

1111
/** Add this cancellable to the given group after removing it from the previous group in which it was.
1212
*/
1313
def link(group: CompletionGroup): this.type = synchronized:
14-
this.group.drop(this)
14+
if this.group != null then this.group.drop(this)
1515
this.group = group
1616
this.group.add(this)
1717
this

shared/src/main/scala/async/CompletionGroup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object CompletionGroup:
4646
/** A sentinel group of cancellables that are in fact not linked to any real group. `cancel`, `add`, and `drop` do
4747
* nothing when called on this group.
4848
*/
49-
val Unlinked = new CompletionGroup:
49+
object Unlinked extends CompletionGroup:
5050
override def cancel(): Unit = ()
5151
override def waitCompletion()(using Async): Unit = ()
5252
override def add(member: Cancellable): Unit = ()

0 commit comments

Comments
 (0)