Automatic fit buffer size to memory page size.
auto q1 = new Queue!int; assert(q1.size == 1023); auto q2 = new Queue!long; assert(q2.size == 511);
Pending and available.
auto q = new Queue!int(3); assert(q.pending == 0); assert(q.available == 3); q.put(7); assert(q.pending == 1); assert(q.available == 2); q.put(77); assert(q.pending == 2); assert(q.available == 1); q.put(777); assert(q.pending == 3); assert(q.available == 0); assert(q.front == 7); q.popFront; assert(q.pending == 2); assert(q.available == 1); assert(q.front == 77); q.popFront; assert(q.pending == 1); assert(q.available == 2); assert(q.front == 777); q.popFront; assert(q.pending == 0); assert(q.available == 3);
Consume from empty is forbidden.
import core.exception; auto q = new Queue!int(1); q.provider.finalize(); q.front.assertThrown!AssertError; q.popFront.assertThrown!AssertError;
Provide to full is forbidden.
import core.exception; auto q = new Queue!int(1); q.consumer.finalize(); q.put(7); q.put(77).assertThrown!AssertError;
Make struct inside put.
struct Foo { int a; int b; } auto q = new Queue!Foo; q.put!Foo(7, 13); assert(q.front == Foo(7, 13));
Consume current pending message. pending must be checked before.