diff options
author | Alex Chronopoulos <[email protected]> | 2016-03-07 18:31:32 +0200 |
---|---|---|
committer | Alex Chronopoulos <[email protected]> | 2016-03-08 13:09:03 +0200 |
commit | b08fd093d70bdbeb6520ed8112caefa22060a055 (patch) | |
tree | aedf5d0890a63788139a1801cccc5e355a789881 /src/cubeb_ring_array.h | |
parent | 6c782af0e76b9bc6c05c4c63c765f71ff6ff0488 (diff) | |
download | cubeb-b08fd093d70bdbeb6520ed8112caefa22060a055.tar.gz cubeb-b08fd093d70bdbeb6520ed8112caefa22060a055.zip |
Remove synchronization from ring array
Diffstat (limited to 'src/cubeb_ring_array.h')
-rw-r--r-- | src/cubeb_ring_array.h | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/src/cubeb_ring_array.h b/src/cubeb_ring_array.h index adf96a2..642c1cb 100644 --- a/src/cubeb_ring_array.h +++ b/src/cubeb_ring_array.h @@ -23,7 +23,6 @@ typedef struct { unsigned int tail; /**< Index of the last element (first to deliver). */ int count; /**< Number of elements in the array. */ unsigned int capacity; /**< Total length of the array. */ - pthread_mutex_t mutex; /**< Mutex to synchronize store/fetch. */ } ring_array; /** Initialize the ring array. @@ -37,16 +36,9 @@ ring_array_init(ring_array * ra) ra->count = 0; memset(ra->pointer_array, 0, sizeof(ra->pointer_array)); - pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_DEFAULT); - int ret = pthread_mutex_init(&ra->mutex, &attr); - assert(ret == 0); - pthread_mutexattr_destroy(&attr); - assert(ra->pointer_array[0] == NULL); - return ret; + return 0; } /** Set the allocated space to store the data. @@ -70,7 +62,6 @@ ring_array_set_data(ring_array * ra, void * data, unsigned int index) void ring_array_destroy(ring_array * ra) { - pthread_mutex_destroy(&ra->mutex); } /** Get the allocated buffer to be stored with fresh data. @@ -79,13 +70,8 @@ ring_array_destroy(ring_array * ra) void * ring_array_store_buffer(ring_array * ra) { - int rv = pthread_mutex_lock(&ra->mutex); - assert(rv == 0); - assert(ra->pointer_array[0] != NULL); - if (ra->count == (int)ra->capacity) { - pthread_mutex_unlock(&ra->mutex); return NULL; } @@ -95,7 +81,6 @@ ring_array_store_buffer(ring_array * ra) ++ra->count; assert(ra->count <= (int)ra->capacity); - pthread_mutex_unlock(&ra->mutex); return ret; } @@ -105,13 +90,9 @@ ring_array_store_buffer(ring_array * ra) void * ring_array_fetch_buffer(ring_array * ra) { - int rv = pthread_mutex_lock(&ra->mutex); - assert(rv == 0); - assert(ra->pointer_array[0] != NULL); if (ra->count == 0) { - pthread_mutex_unlock(&ra->mutex); return NULL; } void * ret = ra->pointer_array[ra->tail]; @@ -122,7 +103,6 @@ ring_array_fetch_buffer(ring_array * ra) ra->count--; assert(ra->count >= 0); - pthread_mutex_unlock(&ra->mutex); return ret; } |