MpscBoundedQueue

Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

dequeue
bool dequeue(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
enqueue
bool enqueue(T value)
Undocumented in source. Be warned that the author may not have intended to support it.
peek
bool peek(T value)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

import libd.threading, libd.util.errorhandling;
MpscBoundedQueue!(int, 10*100) queue;

foreach(i; 0..10)
{
    threadRun((typeof(queue)* ptr)
    {
        foreach(i; 0..1000)
        {
            import std;
            ptr.enqueue(i);
            sleep(uniform(0, 50).msecs);
        }
        return SimpleResult!void.init;
    }, &queue);
}

int sum;
int num;
while(queue.dequeue(num))
{
    import std;
    writeln(num, " ", sum);
    sum += num;
    sleep(100.msecs);
}

Meta