Manager
- 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`
This commit is contained in:
parent
aff9787dba
commit
c5a6612a4b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue