Fix some unlisted bugs in std.parallelism.

This commit is contained in:
dsimcha 2011-06-02 09:24:47 -04:00
parent 8c0f365f9e
commit 58656cd76f

View file

@ -2151,16 +2151,18 @@ public:
); );
} }
try { if(tasks.length > 0) {
(cast(AbstractTask*) &tasks[0]).job(); try {
} catch(Throwable e) { (cast(AbstractTask*) &tasks[0]).job();
tasks[0].exception = e; } catch(Throwable e) {
} tasks[0].exception = e;
tasks[0].taskStatus = TaskStatus.done; }
tasks[0].taskStatus = TaskStatus.done;
// Try to execute each of these in the current thread // Try to execute each of these in the current thread
foreach(ref task; tasks[1..$]) { foreach(ref task; tasks[1..$]) {
tryDeleteExecute( cast(AbstractTask*) &task); tryDeleteExecute( cast(AbstractTask*) &task);
}
} }
// Now that we've tried to execute every task, they're all either // Now that we've tried to execute every task, they're all either
@ -2950,18 +2952,6 @@ private mixin template ResubmittingTasks() {
pool.abstractPutGroupNoSync(head, tail); pool.abstractPutGroupNoSync(head, tail);
} }
AbstractTask* first; // Do in this thread.
void doFirst() {
if(first is null) return;
try {
first.job();
} catch(Throwable e) {
first.exception = e;
}
atomicSetUbyte(first.taskStatus, TaskStatus.done);
}
// Search for slots. // Search for slots.
foreach(ref task; tasks) { foreach(ref task; tasks) {
try { try {
@ -2981,10 +2971,7 @@ private mixin template ResubmittingTasks() {
assert(task.next is null); assert(task.next is null);
assert(task.prev is null); assert(task.prev is null);
if(first is null) { if(head is null) {
first = cast(AbstractTask*) &task;
first.taskStatus = TaskStatus.inProgress;
} else if(head is null) {
head = tail = cast(AbstractTask*) &task; head = tail = cast(AbstractTask*) &task;
} else { } else {
auto at = cast(AbstractTask*) &task; auto at = cast(AbstractTask*) &task;
@ -2996,14 +2983,12 @@ private mixin template ResubmittingTasks() {
if(emptyCheck()) { if(emptyCheck()) {
doGroupSubmit(); doGroupSubmit();
atomicSetUbyte(doneSubmitting, 1); atomicSetUbyte(doneSubmitting, 1);
doFirst();
return; return;
} }
} }
doGroupSubmit(); doGroupSubmit();
submitResubmittingTask(cast(AbstractTask*) &submitNextBatch); submitResubmittingTask(cast(AbstractTask*) &submitNextBatch);
doFirst();
} }
void submitAndExecute() { void submitAndExecute() {