diff --git a/source/tristanable/manager/manager.d b/source/tristanable/manager/manager.d index 6ed2bad..291e4e5 100644 --- a/source/tristanable/manager/manager.d +++ b/source/tristanable/manager/manager.d @@ -93,20 +93,51 @@ public class Manager * Stops the management of the socket, resulting * in ending the updating of queues and closing * the underlying connection + * + * Calling this will also unblock any calls that + * were blocking whilst doing a `dequeue()` */ public void stop() + { + /* Stop with the given reason */ + stop(ErrorType.MANAGER_SHUTDOWN); + } + + /** + * Only called by the `Watcher` and for + * the purpose of setting a custom error + * type. + * + * Called when the network read fails + */ + void stop_FailedWatcher() + { + /* Stop with the given reason */ + stop(ErrorType.WATCHER_FAILED); + } + + /** + * Stops the watcher service and then + * unblocks all calls to `dequeue()` + * by shutting down each `Queue` + * + * Params: + * reason = the reason for the + * shutdown + */ + private void stop(ErrorType reason) { /* Stop the watcher */ watcher.shutdown(); /* Unblock all `dequeue()` calls */ - shutdownAllQueues(); + shutdownAllQueues(reason); } /** * Shuts down all registered queues */ - protected void shutdownAllQueues() + protected void shutdownAllQueues(ErrorType reason) { /* Lock the queue of queues */ queuesLock.lock(); @@ -121,7 +152,7 @@ public class Manager /* Shutdown each queue */ foreach(Queue queue; this.queues) { - queue.shutdownQueue(ErrorType.MANAGER_SHUTDOWN); + queue.shutdownQueue(reason); } }