summaryrefslogtreecommitdiff
path: root/rts/Task.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2014-02-27 14:07:29 +0000
committerSimon Marlow <marlowsd@gmail.com>2014-02-27 14:07:34 +0000
commitaf6746fb6b5adb5ba5be6e0f647c4ebe767ce084 (patch)
treefce2e5cf3989597d3a1446f68c18d82bb9d1403f /rts/Task.c
parent68c0d8689dd93cb0ce74a288e82f2ed997c31acc (diff)
downloadhaskell-af6746fb6b5adb5ba5be6e0f647c4ebe767ce084.tar.gz
Add hs_thread_done() (#8124)
See documentation for details.
Diffstat (limited to 'rts/Task.c')
-rw-r--r--rts/Task.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/rts/Task.c b/rts/Task.c
index a044bc3672..12c22c4b02 100644
--- a/rts/Task.c
+++ b/rts/Task.c
@@ -134,6 +134,44 @@ allocTask (void)
}
}
+void freeMyTask (void)
+{
+ Task *task;
+
+ task = myTask();
+
+ if (task == NULL) return;
+
+ if (!task->stopped) {
+ errorBelch(
+ "freeMyTask() called, but the Task is not stopped; ignoring");
+ return;
+ }
+
+ if (task->worker) {
+ errorBelch("freeMyTask() called on a worker; ignoring");
+ return;
+ }
+
+ ACQUIRE_LOCK(&all_tasks_mutex);
+
+ if (task->all_prev) {
+ task->all_prev->all_next = task->all_next;
+ } else {
+ all_tasks = task->all_next;
+ }
+ if (task->all_next) {
+ task->all_next->all_prev = task->all_prev;
+ }
+
+ taskCount--;
+
+ RELEASE_LOCK(&all_tasks_mutex);
+
+ freeTask(task);
+ setMyTask(NULL);
+}
+
static void
freeTask (Task *task)
{
@@ -219,7 +257,7 @@ newInCall (Task *task)
task->spare_incalls = incall->next;
task->n_spare_incalls--;
} else {
- incall = stgMallocBytes((sizeof(InCall)), "newBoundTask");
+ incall = stgMallocBytes((sizeof(InCall)), "newInCall");
}
incall->tso = NULL;