summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cqueue.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-06-14 13:24:29 +0200
committerTyge Løvset <[email protected]>2023-06-14 13:24:29 +0200
commit3f919a3b38a88e1c96399cd6096dec16060802a1 (patch)
tree8c071e33522d31cd7c90834423760da514fc7f46 /include/stc/cqueue.h
parentc51bdc8d8aeac63c0af955f81593ef0be326a7e0 (diff)
downloadSTC-modified-3f919a3b38a88e1c96399cd6096dec16060802a1.tar.gz
STC-modified-3f919a3b38a88e1c96399cd6096dec16060802a1.zip
Fixed a bug in cco_await_on(), and added _pull() function to random access containers (moves element out of container, ie no drop).
Diffstat (limited to 'include/stc/cqueue.h')
-rw-r--r--include/stc/cqueue.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index 3adc1bcb..aa3d7384 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -93,6 +93,13 @@ STC_INLINE void _cx_memb(_pop)(_cx_self* self) { // pop_front
self->start = (self->start + 1) & self->capmask;
}
+STC_INLINE _cx_value _cx_memb(_pull)(_cx_self* self) { // move front out of queue
+ assert(!_cx_memb(_empty)(self));
+ intptr_t s = self->start;
+ self->start = (s + 1) & self->capmask;
+ return self->data[s];
+}
+
STC_INLINE void _cx_memb(_copy)(_cx_self* self, const _cx_self* other) {
if (self->data == other->data) return;
_cx_memb(_drop)(self);
@@ -162,7 +169,7 @@ _cx_memb(_reserve)(_cx_self* self, const intptr_t n) {
if (!data)
return false;
intptr_t head = oldcap - self->start;
- if (self->start < self->end || self->start == 0)
+ if (self->start <= self->end)
;
else if (head < self->end) {
self->start = newcap - head;