Added some exceptional stuff

This commit is contained in:
Tristan B. Velloza Kildaire 2021-09-08 20:24:45 +02:00
parent 6382343916
commit 1b88d1f8bf
1 changed files with 17 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import tristanable.queueitem : QueueItem;
import tristanable.manager : Manager;
import core.thread : Thread;
import tristanable.encoding;
import tristanable.exceptions;
public final class Watcher : Thread
{
@ -17,7 +18,7 @@ public final class Watcher : Thread
/* The socket to read from */
private Socket socket;
// private bool running;
private bool running;
this(Manager manager, Socket endpoint)
{
@ -31,8 +32,11 @@ public final class Watcher : Thread
public void shutdown()
{
running=false;
/* Close the socket, causing an error, breaking the event loop */
socket.close();
}
private void run()
@ -74,6 +78,8 @@ public final class Watcher : Thread
/* If the receive failed */
else
{
/* TODO: depending on `running`, different error */
/* TODO: Stop everything */
break;
}
@ -87,5 +93,15 @@ public final class Watcher : Thread
*/
Thread.getThis().yield();
}
/* Check if we had an error */
if(running)
{
throw new TristanableException(manager, "bformat socket error");
}
else
{
/* Actual shut down, do nothing */
}
}
}