One must now explicitly start tristanable

This commit is contained in:
Tristan B. Velloza Kildaire 2022-05-19 18:40:25 +02:00
parent 35e7b6e3b3
commit 9da01c7376
4 changed files with 26 additions and 9 deletions

View File

@ -35,6 +35,9 @@ Queue instantNotification = new Queue(2);
manager.addQueue(weatherQueue);
manager.addQueue(instantNotification);
/* We can tell tristanable to start reading from the socket now */
manager.start();
/* Now we can block on this queue and return with its head */
QueueItem message = weatherQueue.dequeue();
```

View File

@ -52,9 +52,6 @@ public final class Manager
{
/* TODO: Make sure the socket is in STREAM mode */
/* Set this session as alive */
this.isAlive = true;
/* Set the socket */
this.socket = socket;
@ -65,6 +62,18 @@ public final class Manager
watcher = new Watcher(this, socket, timeOut, newSys);
}
/**
* Starts the session (watcher)
*/
public void start()
{
/* Set this session as alive */
this.isAlive = true;
/* Start the watcher */
watcher.start();
}
public Queue getQueue(ulong tag)
{
Queue matchingQueue;

View File

@ -43,11 +43,7 @@ public final class Watcher : Thread
initSelect();
}
this.timeOut = timeOut;
running = true;
start();
this.timeOut = timeOut;
}
/**
@ -72,6 +68,8 @@ public final class Watcher : Thread
private void run()
{
running = true;
/* Continuously dequeue tristanable packets from socket */
while(true)
{

9
todo
View File

@ -24,4 +24,11 @@
- [x] Add checks in `Queue` class
- [ ] New sys, before calling `continue`, should `yield()`
- [ ] New sys, before calling `continue`, should `yield()`
- [x] Add `.start()`, don't start the watcher immediately
- [x] Code
- [x] Documentation