1
1

Provide a way to look at the head of the ring

This commit was SVN r24832.
Этот коммит содержится в:
Ralph Castain 2011-06-28 19:46:48 +00:00
родитель 93110ce805
Коммит 9244ea10fb
2 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -144,6 +144,13 @@ void* opal_ring_buffer_pop(opal_ring_buffer_t *ring)
OPAL_ACQUIRE_THREAD(&(ring->lock), &(ring->cond), &(ring->in_use)); OPAL_ACQUIRE_THREAD(&(ring->lock), &(ring->cond), &(ring->in_use));
if (ring->size <= i || -1 == ring->tail) { if (ring->size <= i || -1 == ring->tail) {
p = NULL; p = NULL;
} else if (i < 0) {
/* return the value at the head of the ring */
if (ring->head == 0) {
p = ring->addr[ring->size - 1];
} else {
p = ring->addr[ring->head - 1];
}
} else { } else {
/* calculate the offset of the tail in the ring */ /* calculate the offset of the tail in the ring */
offset = ring->tail + i; offset = ring->tail + i;

Просмотреть файл

@ -95,7 +95,8 @@ OPAL_DECLSPEC void* opal_ring_buffer_pop(opal_ring_buffer_t *ring);
/* /*
* Access an element of the ring, without removing it, indexed * Access an element of the ring, without removing it, indexed
* starting at the tail * starting at the tail - a value of -1 will return the element
* at the head of the ring
*/ */
OPAL_DECLSPEC void* opal_ring_buffer_poke(opal_ring_buffer_t *ring, int i); OPAL_DECLSPEC void* opal_ring_buffer_poke(opal_ring_buffer_t *ring, int i);