Added shutdown capability

This commit is contained in:
Tristan B. Velloza Kildaire 2021-09-08 11:19:05 +02:00
parent 5f16e8d5b0
commit bfa4364a99
2 changed files with 15 additions and 0 deletions

View File

@ -115,5 +115,11 @@ public final class Manager
public void shutdown()
{
/* TODO: Implement me */
/* Make the loop stop whenever it does */
watcher.shutdown();
/* Wait for the thread to end */
watcher.join();
}
}

View File

@ -17,15 +17,24 @@ public final class Watcher : Thread
/* The socket to read from */
private Socket socket;
// private bool running;
this(Manager manager, Socket endpoint)
{
super(&run);
this.manager = manager;
socket = endpoint;
// running = true;
start();
}
public void shutdown()
{
/* Close the socket, causing an error, breaking the event loop */
socket.close();
}
private void run()
{
/* Continuously dequeue tristanable packets from socket */