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
- Replace inner-class projections with facade interfaces as a work-around to the compiler bug I discovered: see scala/scala3#22508
AssistantBasedDoerProvider:
- Make `DoerAssistantProvider` use a type parameter instead of an abstract type member to allow/simplify the propagation of the type of the provided assistant.
- Add the assistant type as a type parameter.
SchedulingAssistant:
- correct the enabled schedules not being remembered bug.
@@ -100,12 +104,12 @@ class SharedQueueDoerAssistantProvider(
100
104
/** Executes all the pending tasks that are visible from the calling [[Worker.thread]].
101
105
*
102
106
* Note: The [[taskQueueSize]] is decremented not immediately after polling a task from the [[taskQueue]] but only after the task is executed.
103
-
* This ensures that another thread invoking `queuedForSequentialExecution` does not call [[wakeUpASleepingWorkerIfAny]] passing this [[DoerAssistant]] or enqueue this [[DoerAssistant]] into the [[queuedDoersAssistants]] queue,
104
-
* which would violate the constraint that prevents two workers from being assigned to the same [[DoerAssistant]] instance simultaneously.
107
+
* This ensures that another thread invoking `queuedForSequentialExecution` does not call [[wakeUpASleepingWorkerIfAny]] passing this [[DoerAssistantImpl]] or enqueue this [[DoerAssistantImpl]] into the [[queuedDoersAssistants]] queue,
108
+
* which would violate the constraint that prevents two workers from being assigned to the same [[DoerAssistantImpl]] instance simultaneously.
105
109
*
106
-
* If at least one pending task remains unconsumed — typically because it is not yet visible from the [[Worker.thread]] — this [[DoerAssistant]] is enqueued into the [[queuedDoersAssistants]] queue to be assigned to a worker at a later time.
110
+
* If at least one pending task remains unconsumed — typically because it is not yet visible from the [[Worker.thread]] — this [[DoerAssistantImpl]] is enqueued into the [[queuedDoersAssistants]] queue to be assigned to a worker at a later time.
@@ -121,7 +125,7 @@ class SharedQueueDoerAssistantProvider(
121
125
task.run()
122
126
processedTasksCounter +=1
123
127
aDecrementIsPending =false
124
-
// the `taskQueueSize` must be decremented after (not before) running the task to avoid that other thread executing `queuedForSequentialExecution` to enqueue this DoerAssistant into `queuedDoersAssistants` allowing the worst problem to occur: two workers assigned to the same DoerAssistant.
128
+
// the `taskQueueSize` must be decremented after (not before) running the task to avoid that other thread executing `queuedForSequentialExecution` to enqueue this SchedulingAssistantImpl into `queuedDoersAssistants` allowing the worst problem to occur: two workers assigned to the same SchedulingAssistantImpl.
* The provided [[DoerAssistant]] will be assigned to the awakened worker.
147
-
* Asumes the provided [[DoerAssistant]] is and will not be enqueued in [[queuedDoersAssistants]], which ensures it will not be assigned to any other worker simultaneously. */
* The provided [[DoerAssistantImpl]] will be assigned to the awakened worker.
153
+
* Asumes the provided [[DoerAssistantImpl]] is and will not be enqueued in [[queuedDoersAssistants]], which ensures it will not be assigned to any other worker simultaneously. */
if debugEnabled then assert(!queuedDoersAssistants.contains(stimulator))
150
156
if sleepingWorkersCount.get >0then {
151
157
varworkerIndex= lastAwakenedWorkerIndex -1
@@ -183,12 +189,12 @@ class SharedQueueDoerAssistantProvider(
183
189
privatevarrefusedTriesToSleepsCounter:Int=0
184
190
185
191
/**
186
-
* A [[DoerAssistant]] instance that jumps the queue established by the [[circularIterator]] that determines the order in which the [[DoerAssistant]] instances are assigned to this worker.
192
+
* A [[DoerAssistantImpl]] instance that jumps the queue established by the [[circularIterator]] that determines the order in which the [[DoerAssistantImpl]] instances are assigned to this worker.
187
193
* Should not be modified by any thread other than the [[thread]] of this worker unless this worker is sleeping.
188
-
* Is set by [[wakeUpIfSleeping]] while this worker is sleeping, and by [[run]] after calling [[DoerAssistant.executePendingTasks()]] if the task-queue was not completely emptied;
194
+
* Is set by [[wakeUpIfSleeping]] while this worker is sleeping, and by [[run]] after calling [[DoerAssistantImpl.executePendingTasks()]] if the task-queue was not completely emptied;
189
195
* is read by this worker after it is awakened;
190
196
* and is cleared by this worker after it is awakened. */
191
-
privatevarqueueJumper:DoerAssistant|Null=null
197
+
privatevarqueueJumper:DoerAssistantImpl|Null=null
192
198
193
199
/**
194
200
* Remember the greatest value that [[refusedTriesToSleepsCounter]] reached before it has been reset because a pending task becomes visible.
@@ -215,7 +221,7 @@ class SharedQueueDoerAssistantProvider(
215
221
overridedefrun():Unit= {
216
222
workerIndexThreadLocal.set(index)
217
223
while keepRunning do {
218
-
valassignedDoerAssistant:DoerAssistant|Null=
224
+
valassignedDoerAssistant:DoerAssistantImpl|Null=
219
225
if queueJumper !=nullthen queueJumper
220
226
else queuedDoersAssistants.poll()
221
227
queueJumper =null
@@ -227,13 +233,13 @@ class SharedQueueDoerAssistantProvider(
catch { // TODO analyze if clarity would suffer too much if [[DoerAssistant.executePendingTasks]] accepted a partial function with this catch removing the necessity of this try-catch.
236
+
catch { // TODO analyze if clarity would suffer too much if [[SchedulingAssistantImpl.executePendingTasks]] accepted a partial function with this catch removing the necessity of this try-catch.
231
237
casee: Throwable=>
232
238
if thread.getUncaughtExceptionHandler ==null&&Thread.getDefaultUncaughtExceptionHandler ==nullthen failureReporter(e)
233
239
// Let the current thread to terminate abruptly, create a new one, and start it with the same Runnable (this worker).
234
240
thisWorker.synchronized {
235
241
thread = threadFactory.newThread(this)
236
-
// Memorize the assigned DoerAssistant such that the new thread be assigned to the same [[DoerAssistant]]. It will continue with the task after the one that threw the exception.
242
+
// Memorize the assigned SchedulingAssistantImpl such that the new thread be assigned to the same [[SchedulingAssistantImpl]]. It will continue with the task after the one that threw the exception.
237
243
queueJumper = assignedDoerAssistant
238
244
}
239
245
thread.start()
@@ -284,11 +290,11 @@ class SharedQueueDoerAssistantProvider(
284
290
}
285
291
286
292
/** Wakes up this [[Worker]] if it is currently sleeping.
287
-
* @paramstimulator the [[DoerAssistant]] to be assigned to this worker upon awakening,
293
+
* @paramstimulator the [[DoerAssistantImpl]] to be assigned to this worker upon awakening,
288
294
* provided it has not already been assigned to another [[Worker]].
289
295
* @return `true` if this worker was sleeping and has been awakened, otherwise `false`.
0 commit comments