@@ -410,7 +410,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
410
410
* into heap to avoid overflow and corruption of heap data structure.
411
411
*/
412
412
@JvmField var nanoTime : Long
413
- ) : Runnable, Comparable<DelayedTask>, DisposableHandle, ThreadSafeHeapNode {
413
+ ) : Runnable, Comparable<DelayedTask>, DisposableHandle, ThreadSafeHeapNode, SynchronizedObject() {
414
414
@Volatile
415
415
private var _heap : Any? = null // null | ThreadSafeHeap | DISPOSED_TASK
416
416
@@ -434,8 +434,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
434
434
435
435
fun timeToExecute (now : Long ): Boolean = now - nanoTime >= 0L
436
436
437
- @Synchronized
438
- fun scheduleTask (now : Long , delayed : DelayedTaskQueue , eventLoop : EventLoopImplBase ): Int {
437
+ fun scheduleTask (now : Long , delayed : DelayedTaskQueue , eventLoop : EventLoopImplBase ): Int = synchronized<Int >(this ) {
439
438
if (_heap == = DISPOSED_TASK ) return SCHEDULE_DISPOSED // don't add -- was already disposed
440
439
delayed.addLastIf(this ) { firstTask ->
441
440
if (eventLoop.isCompleted) return SCHEDULE_COMPLETED // non-local return from scheduleTask
@@ -477,8 +476,7 @@ internal abstract class EventLoopImplBase: EventLoopImplPlatform(), Delay {
477
476
return SCHEDULE_OK
478
477
}
479
478
480
- @Synchronized
481
- final override fun dispose () {
479
+ final override fun dispose (): Unit = synchronized(this ) {
482
480
val heap = _heap
483
481
if (heap == = DISPOSED_TASK ) return // already disposed
484
482
(heap as ? DelayedTaskQueue )?.remove(this ) // remove if it is in heap (first)
0 commit comments