Skip to content

Commit

Permalink
Manager
Browse files Browse the repository at this point in the history
- Updated documentation for `stop()`
- Added `stop(ErrorType)` which will let you set the error type used for unblocking the `dequeue()` calls
- Added `stop_FailedWatcher()` which sets the `ErrorType` to `WATCHER_FAILED`
- `shutdownAllQueues()` now takes in a `ErrorType`
  • Loading branch information
deavmi committed Nov 26, 2023
1 parent aff9787 commit c5a6612
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions source/tristanable/manager/manager.d
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -121,7 +152,7 @@ public class Manager
/* Shutdown each queue */
foreach(Queue queue; this.queues)
{
queue.shutdownQueue(ErrorType.MANAGER_SHUTDOWN);
queue.shutdownQueue(reason);
}
}

Expand Down

0 comments on commit c5a6612

Please sign in to comment.