From e7f93cd78a963d7be6aa82fbff3defb596abedad Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 26 Feb 2023 22:24:49 +0200 Subject: [PATCH] - Upgraded to working version of `libsnooze` (compilation-wise) - Fixed imports and missing definitions in `queue` module --- .gitignore | 1 + dub.json | 2 +- source/tristanable/queue.d | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 74b926f..d8386d5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ docs/ # Code coverage *.lst +source/tristanable/queue.d diff --git a/dub.json b/dub.json index dc00faa..82518e0 100644 --- a/dub.json +++ b/dub.json @@ -4,7 +4,7 @@ ], "copyright": "Copyright © 2023, Tristan B. Kildaire", "dependencies": { - "libsnooze": "0.2.5" + "libsnooze": "0.2.7" }, "description": "Tag-based asynchronous messaging framework", "license": "LGPL-3.0", diff --git a/source/tristanable/queue.d b/source/tristanable/queue.d index c7613da..a21dc24 100644 --- a/source/tristanable/queue.d +++ b/source/tristanable/queue.d @@ -1,10 +1,36 @@ module tristanable.queue; +import libsnooze; +import core.sync.mutex : Mutex; + public class Queue { + /** + * Everytime a thread calls `.dequeue()` on this queue + * + */ + private Event event; + + private QueueItem queue; + private Mutex queueLock; + + private this() { + this.queueLock = new Mutex(); + } + public void dequeue() + { + // TODO: Make us wait on the event (optional with a time-out) + + // TODO: Lock queue + queueLock.lock(); + + // TODO: Get item off queue + + // TODO: Unlock queue + queueLock.unlock(); } public static Queue newQueue(ulong queueID) @@ -15,4 +41,9 @@ public class Queue return queue; } +} + +public class QueueItem +{ + } \ No newline at end of file