Skip to content

deavmi/qix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Qix

Simple waitable-queue management

DDUB DUB DUB Coverage Status


Usage

A basic example of the usage is shown below. Please note that it is only for demonstration purposes. A much more sensible use case is to have one thread calling receive(Message) to enqueue messages and then another thread blocking on wait(Duration) to dequeue a message:

// item type
struct Message
{
	private string _t;
	this(string t)
	{
		this._t = t;
	}

	public string t()
	{
		return this._t;
	}
} 

// queue manager for queues that hold messages
auto m = new Manager!(Message);

// create two new queues
Result!(Queue!(Message)*, string) q1_r = m.newQueue();
Result!(Queue!(Message)*, string) q2_r = m.newQueue();

assert(q1_r.is_okay());
assert(q2_r.is_okay());
auto q1 = q1_r.ok();
auto q2 = q2_r.ok();

// enqueue two messages, one per queue, then read them off
//
// we won't block as the messages are already arrived
Message m1_in = Message("First message");
Message m2_in = Message("Second message");
assert(q1.receive(m1_in)); // should not be rejected
assert(q2.receive(m2_in)); // should not be rejected
assert(q1.wait() == m1_in); // should be the same message we sent in
assert(q2.wait() == m2_in); // should be the same message we sent in

A more sensible threaded example can be found here.

Docs

You can also take a look at the API documentation.

License

The license is the LGPL 2.0 only.

About

Simple waitable-queue management

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages