| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
bool is_empty_state(struct aws_ring_buffer *ring_buf) { |
| 12 |
uint8_t *head = aws_atomic_load_ptr(&ring_buf->head); |
| 13 |
uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail); |
| 14 |
return tail == head; |
| 15 |
} |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
bool is_front_valid_state(struct aws_ring_buffer *ring_buf) { |
| 21 |
uint8_t *head = aws_atomic_load_ptr(&ring_buf->head); |
| 22 |
uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail); |
| 23 |
return ring_buf->allocation == tail && tail < head; |
| 24 |
} |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
bool is_middle_valid_state(struct aws_ring_buffer *ring_buf) { |
| 30 |
uint8_t *head = aws_atomic_load_ptr(&ring_buf->head); |
| 31 |
uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail); |
| 32 |
return ring_buf->allocation < tail && tail < head; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
bool is_ends_valid_state(struct aws_ring_buffer *ring_buf) { |
| 39 |
uint8_t *head = aws_atomic_load_ptr(&ring_buf->head); |
| 40 |
uint8_t *tail = aws_atomic_load_ptr(&ring_buf->tail); |
| 41 |
return tail > head; |
| 42 |
} |