summaryrefslogtreecommitdiffstats
path: root/libdimension/progress.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-09-29 17:49:49 -0400
committerTavian Barnes <tavianator@gmail.com>2010-09-29 19:03:03 -0400
commitcec47afae217cea36779d7dea4437b35dee63be2 (patch)
treec02e964d1381da9543733981040615984743edad /libdimension/progress.c
parent140afde9d7096bea0f8d5f6a04e5c41dd37ab40b (diff)
downloaddimension-cec47afae217cea36779d7dea4437b35dee63be2.tar.xz
Make parts of the progress API internal.
Diffstat (limited to 'libdimension/progress.c')
-rw-r--r--libdimension/progress.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/libdimension/progress.c b/libdimension/progress.c
index aeac2ac..f7a8b62 100644
--- a/libdimension/progress.c
+++ b/libdimension/progress.c
@@ -65,29 +65,6 @@ dmnsn_new_progress()
return progress;
}
-/* Delete a dmnsn_progress*, which has not yet been associated with a thread */
-void
-dmnsn_delete_progress(dmnsn_progress *progress)
-{
- if (progress) {
- if (pthread_rwlock_destroy(progress->rwlock) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking rwlock.");
- }
- if (pthread_mutex_destroy(progress->mutex) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking mutex.");
- }
- if (pthread_cond_destroy(progress->cond) != 0) {
- dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
- }
-
- dmnsn_free(progress->rwlock);
- dmnsn_free(progress->mutex);
- dmnsn_free(progress->cond);
- dmnsn_delete_array(progress->elements);
- dmnsn_free(progress);
- }
-}
-
/* Join the worker thread and delete `progress'. */
int
dmnsn_finish_progress(dmnsn_progress *progress)
@@ -96,6 +73,7 @@ dmnsn_finish_progress(dmnsn_progress *progress)
int retval = -1;
if (progress) {
+ /* Get the thread's return value */
if (pthread_join(progress->thread, &ptr) != 0) {
/* Medium severity because an unjoined thread likely means that the thread
is incomplete or invalid */
@@ -103,10 +81,23 @@ dmnsn_finish_progress(dmnsn_progress *progress)
} else if (ptr) {
retval = *(int *)ptr;
dmnsn_free(ptr);
- /* Wake up all waiters */
- dmnsn_done_progress(progress);
}
- dmnsn_delete_progress(progress);
+
+ /* Free the progress object */
+ if (pthread_rwlock_destroy(progress->rwlock) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking rwlock.");
+ }
+ if (pthread_mutex_destroy(progress->mutex) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking mutex.");
+ }
+ if (pthread_cond_destroy(progress->cond) != 0) {
+ dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
+ }
+ dmnsn_free(progress->rwlock);
+ dmnsn_free(progress->mutex);
+ dmnsn_free(progress->cond);
+ dmnsn_delete_array(progress->elements);
+ dmnsn_free(progress);
}
return retval;