1
0
mirror of https://github.com/deavmi/birchwood synced 2024-09-20 13:43:19 +02:00
- Now catches `SnoozeError` if a the libsnooze `Event`'s failed to have their `ensure()` call succeed

ErrorType

- Updated description for enum member `INTERNAL_FAILURE`

Sender

- Removed now-completed TODO

Receiver

- Removed now-completed TODO
This commit is contained in:
Tristan B. Velloza Kildaire 2023-06-25 17:30:53 +02:00
parent fe9bf31ad5
commit b79a3ad8ee
4 changed files with 18 additions and 3 deletions

View File

@ -19,6 +19,8 @@ import birchwood.client.receiver : ReceiverThread;
import birchwood.client.sender : SenderThread; import birchwood.client.sender : SenderThread;
import birchwood.client.events; import birchwood.client.events;
import libsnooze.exceptions : SnoozeError;
import dlog; import dlog;
package __gshared Logger logger; package __gshared Logger logger;
@ -819,6 +821,10 @@ public class Client : Thread
{ {
throw new BirchwoodException(ErrorType.INTERNAL_FAILURE, e.toString()); throw new BirchwoodException(ErrorType.INTERNAL_FAILURE, e.toString());
} }
catch(SnoozeError e)
{
throw new BirchwoodException(ErrorType.INTERNAL_FAILURE, e.toString());
}
} }
// TODO: Do actual liveliness check here // TODO: Do actual liveliness check here
else else

View File

@ -18,7 +18,10 @@ public enum ErrorType
/** /**
* This could occur from errors with `Eventy` * This could occur from errors with `Eventy`
* when setting up the signal handlers and * when setting up the signal handlers and
* event types * event types. It can also occur if `libsnooze`
* has an error which would occur when calling
* `ensure(Thread)` for the `Receiver` and `Sender`
* threads
*/ */
INTERNAL_FAILURE, INTERNAL_FAILURE,

View File

@ -60,12 +60,15 @@ public final class ReceiverThread : Thread
* *
* Params: * Params:
* client = the Client to associate with * client = the Client to associate with
* Throws:
* `SnoozeError` on failure to construct an
* `Event` or ensure ourselves
*/ */
this(Client client) this(Client client)
{ {
super(&recvHandlerFunc); super(&recvHandlerFunc);
this.client = client; this.client = client;
this.receiveEvent = new Event(); // TODO: Catch any libsnooze error here this.receiveEvent = new Event();
this.recvQueueLock = new Mutex(); this.recvQueueLock = new Mutex();
this.receiveEvent.ensure(this); this.receiveEvent.ensure(this);
} }

View File

@ -52,12 +52,15 @@ public final class SenderThread : Thread
* *
* Params: * Params:
* client = the Client to associate with * client = the Client to associate with
* Throws:
* `SnoozeError` on failure to construct an
* `Event` or ensure ourselves
*/ */
this(Client client) this(Client client)
{ {
super(&sendHandlerFunc); super(&sendHandlerFunc);
this.client = client; this.client = client;
this.sendEvent = new Event(); // TODO: Catch any libsnooze error here this.sendEvent = new Event();
this.sendQueueLock = new Mutex(); this.sendQueueLock = new Mutex();
this.sendEvent.ensure(this); this.sendEvent.ensure(this);
} }