This commit is contained in:
Tristan B. Velloza Kildaire 2023-10-13 17:11:44 -05:00 committed by GitHub
commit e234bd3daf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,12 @@
module tristanable.queue.listener;
// TODO: Implement me
import tristanable.queue;
import tristanable.encoding;
public interface TListener
{
// TODO: See if this is all we need / what we want
public void onQueueReceive(Queue queue, TaggedMessage message);
}

View File

@ -0,0 +1,16 @@
/**
* Queue type and related facilities
*/
module tristanable.queue;
/**
* The Queue type for enqueueing and dequeueing messages
*/
public import tristanable.queue.queue : Queue;
/**
* Interface type for definining listeners which can be hooked
* to queue actions
*/
public import tristanable.queue.listener : TListener;

View File

@ -3,6 +3,8 @@
*/
module tristanable.queue.queue;
import tristanable.queue.listener : TListener;
import core.sync.mutex : Mutex;
import core.sync.condition : Condition;
import core.sync.exception : SyncError;
@ -52,6 +54,18 @@ public class Queue
*/
private Mutex queueLock;
/**
* Attached queue listeners
*/
private SList!(TListener) listeners;
/**
* Lock for the listeners queue
*/
private Mutex listenersLock;
// TODO: Add listener add/remove methods
// TODO: On queue actions add a notificaiton call to the listeners
/**
* If a message is enqueued prior
* to us sleeping then we won't