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