diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-06-29 22:12:48 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-06-29 22:12:48 +0000 |
commit | d13f5f01ad28d2c44c413b98d2742d7b72bbb542 (patch) | |
tree | e33a081d25852aaf3e8157fbbe4f14c3172b0345 /libdimension/dimension | |
parent | bc178c264d12f73dc43357814056f571eb886102 (diff) | |
download | dimension-d13f5f01ad28d2c44c413b98d2742d7b72bbb542.tar.xz |
Remove thread-synchronization from arrays, which was way too slow, and
only really needed for dmnsn_progress anyway.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r-- | libdimension/dimension/array.h | 16 | ||||
-rw-r--r-- | libdimension/dimension/progress.h | 3 |
2 files changed, 4 insertions, 15 deletions
diff --git a/libdimension/dimension/array.h b/libdimension/dimension/array.h index 1c8f601..5d5e50e 100644 --- a/libdimension/dimension/array.h +++ b/libdimension/dimension/array.h @@ -32,9 +32,6 @@ typedef struct { void *ptr; size_t obj_size, length, capacity; - - /* Synchronicity control (pointer so it's not const) */ - pthread_rwlock_t *rwlock; } dmnsn_array; /* Array allocation never returns NULL - if dmnsn_new_array returns, it @@ -42,24 +39,13 @@ typedef struct { dmnsn_array *dmnsn_new_array(size_t obj_size); void dmnsn_delete_array(dmnsn_array *array); -/* Thread-safe atomic array access */ - void dmnsn_array_push(dmnsn_array *array, const void *obj); void dmnsn_array_pop(dmnsn_array *array, void *obj); void dmnsn_array_get(const dmnsn_array *array, size_t i, void *obj); void dmnsn_array_set(dmnsn_array *array, size_t i, const void *obj); +void *dmnsn_array_at(dmnsn_array *array, size_t i); size_t dmnsn_array_size(const dmnsn_array *array); void dmnsn_array_resize(dmnsn_array *array, size_t length); -/* Non-atomic operations for manual locking */ -void *dmnsn_array_at(dmnsn_array *array, size_t i); -size_t dmnsn_array_size_unlocked(const dmnsn_array *array); -void dmnsn_array_resize_unlocked(dmnsn_array *array, size_t length); - -/* Manual locking */ -void dmnsn_array_rdlock(const dmnsn_array *array); -void dmnsn_array_wrlock(dmnsn_array *array); -void dmnsn_array_unlock(const dmnsn_array *array); - #endif /* DIMENSION_ARRAY_H */ diff --git a/libdimension/dimension/progress.h b/libdimension/dimension/progress.h index 7958ab9..57a38b6 100644 --- a/libdimension/dimension/progress.h +++ b/libdimension/dimension/progress.h @@ -44,6 +44,9 @@ typedef struct { /* The worker thread */ pthread_t thread; + /* Read-write synchronization */ + pthread_rwlock_t *rwlock; + /* Condition variable for waiting for a particular amount of progress */ pthread_cond_t *cond; pthread_mutex_t *mutex; |