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
- Move `ScheduleImpl` inside `DoerAssistant`.
- Add the `DoerAssistant.ScheduleImpl.isActive` field to avoid the more used `heapIndex` and `isEnabled` fields have to be @volatile.
- Factor out the common code of the `scheduler` command methods into the new `scheduler.signal` method.
- Add the `scheduler.enabledSchedulesByAssistant` to be able to iterator over the enabled schedules when `cancelAll` is called or the `scheduler` is stopped.
/** Exposes the number of executions of the [[Runnable]] that were skipped before the current one due to processing power saturation or negative `initialDelay`.
229
+
* It is calculated based on the scheduled interval, and the difference between the actual [[startingTime]] and the scheduled time:
230
+
* {{{ (actualTime - scheduledTime) / interval }}}
231
+
* Updated before the [[Runnable]] is run.
232
+
* The value of this variable is used after the [[runnable]]'s execution completes to calculate the [[scheduledTime]]; therefore, the [[runnable]] may modify it to affect the resulting [[scheduledTime]] and therefore when it's next execution will be.
233
+
* Intended to be accessed only within the thread that is currently running the [[Runnable]] that is scheduled by this instance. */
234
+
varnumOfSkippedExecutions:Long=0
235
+
/** Exposes the [[System.nanoTime]] when the current execution started.
236
+
* The [[numOfSkippedExecutions]] is calculated based on this time.
237
+
* Updated before the [[Runnable]] is run.
238
+
* Intended to be accessed only within the thread that is currently running the [[Runnable]] that is scheduled by this instance. */
239
+
varstartingTime:NanoTime=0L
240
+
/** An instance becomes enabled when the [[scheduledTime]] is reached, and it's [[runnable]] is enqueued in [[thisDoerAssistant.taskQueue]].
241
+
* An instance becomes disabled after the [[runnable]] execution finishes and the */
/** An instance becomes active when is passed to the [[thisDoerAssistant.scheduleSequentially]] method.
244
+
* An instances becomes inactive when it is passed to the [[thisDoerAssistant.cancel]] method or when [[thisDoerAssistant.cancelAll]] is called.
245
+
*
246
+
* Implementation note: This var may be replaced with {{{ def isActive = !isEnabled && heapIndex < 0}}} but that would require both [[isEnabled]] and [[heapIndex]] to be @volatile. */
* Replaces the element at position `holeIndex` of the heap-based array with the `providedElement` and rearranges it and its parents as necessary to ensure that all parents are less than or equal to their children.
544
609
* Note that for the entire heap to satisfy the min-heap property, the `providedElement` must be less than or equal to the children of `holeIndex`.
545
610
* Sifts element added at bottom up to its heap-ordered spot.
@@ -565,7 +630,7 @@ class SchedulingAssistantProvider(
565
630
* Replaces the element that is currently at position `holeIndex` of the heap-based array with the `providedElement` and rearranges the elements in the subtree rooted at `holeIndex` such that the subtree conform to the min-heap property.
566
631
* Sifts element added at top down to its heap-ordered spot.
/** Exposes the time the [[Runnable]] is expected to be run.
607
-
* Updated after the [[Runnable]] execution is completed. */
608
-
varscheduledTime:NanoTime=0L
609
-
@volatile varheapIndex:Int=-1
610
-
/** Exposes the number of executions of the [[Runnable]] that were skipped before the current one due to processing power saturation or negative `initialDelay`.
611
-
* It is calculated based on the scheduled interval, and the difference between the actual [[startingTime]] and the scheduled time:
612
-
* {{{ (actualTime - scheduledTime) / interval }}}
613
-
* Updated before the [[Runnable]] is run.
614
-
* The value of this variable is used after the [[runnable]]'s execution completes to calculate the [[scheduledTime]]; therefore, the [[runnable]] may modify it to affect the resulting [[scheduledTime]] and therefore when it's next execution will be.
615
-
* Intended to be accessed only within the thread that is currently running the [[Runnable]] that is scheduled by this instance. */
616
-
varnumOfSkippedExecutions:Long=0
617
-
/** Exposes the [[System.nanoTime]] when the current execution started.
618
-
* The [[numOfSkippedExecutions]] is calculated based on this time.
619
-
* Updated before the [[Runnable]] is run.
620
-
* Intended to be accessed only within the thread that is currently running the [[Runnable]] that is scheduled by this instance. */
621
-
varstartingTime:NanoTime=0L
622
-
}
623
-
624
668
/**
625
669
* Makes this [[Matrix.DoerAssistantProvider]] to shut down when all the workers are sleeping.
626
670
* Invocation has no additional effect if already shut down.
0 commit comments