mirror of
https://github.com/deavmi/birchwood
synced 2024-09-20 11:43:22 +02:00
Receiver
- On call to `rq(byte[])` by the `Client` thread wake up the `Receiver` thread - Added a TODO about the first call to `notifyAll()` - Added a `wait()` call - Removed `yield()` calls Sender - On call to `sq(byte[])` by the `Client` thread wake up the `Sender` thread - Added a TODO about the first call to `notifyAll()` - Added a `wait()` call - Removed `yield()` calls Client - Ensure we wake up the `Receiver` and `Sender` threads such that they don't hang on their calls to `wait()` - Added a TODO comment
This commit is contained in:
parent
e3bce71df3
commit
f30fc6b18c
@ -661,6 +661,12 @@ public class Client : Thread
|
||||
socket.close();
|
||||
logger.log("disconnect() socket closed");
|
||||
|
||||
// TODO: See libsnooze notes in `receiver.d` and `sender.d`, we could technically in some
|
||||
// ... teribble situation have a unregistered situaion which would then have a fallthrough
|
||||
// ... notify and a wait which never wakes up (the solution is mentioned in `receiver.d`/`sender.d`)
|
||||
receiver.end();
|
||||
sender.end();
|
||||
|
||||
/* Wait for receive queue manager to realise it needs to stop */
|
||||
receiver.join();
|
||||
logger.log("disconnect() recvQueue manager stopped");
|
||||
|
@ -63,7 +63,15 @@ public final class ReceiverThread : Thread
|
||||
/* Unlock queue */
|
||||
recvQueueLock.unlock();
|
||||
|
||||
// TODO: Add libsnooze event wake up
|
||||
// TODO: Add a "register" function which can initialize pipes
|
||||
// ... without needing a wait, we'd need a ready flag though
|
||||
// ... for receiver's thread start
|
||||
|
||||
/**
|
||||
* Wake up all threads waiting on this event
|
||||
* (if any, and if so it would only be the receiver)
|
||||
*/
|
||||
receiveEvent.notifyAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,6 +99,10 @@ public final class ReceiverThread : Thread
|
||||
|
||||
// TODO: We could look at libsnooze wait starvation or mutex racing (future thought)
|
||||
|
||||
// TODO: See above notes about libsnooze behaviour due
|
||||
// ... to usage in our context
|
||||
receiveEvent.wait(); // TODO: Catch any exceptions from libsnooze
|
||||
|
||||
/* Lock the receieve queue */
|
||||
recvQueueLock.lock();
|
||||
|
||||
@ -185,14 +197,15 @@ public final class ReceiverThread : Thread
|
||||
client.engine.push(ircEvent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Unlock the receive queue */
|
||||
recvQueueLock.unlock();
|
||||
|
||||
/* TODO: Threading yield here */
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
||||
public void end()
|
||||
{
|
||||
// TODO: See above notes about libsnooze behaviour due
|
||||
// ... to usage in our context
|
||||
receiveEvent.notifyAll();
|
||||
}
|
||||
}
|
@ -58,7 +58,15 @@ public final class SenderThread : Thread
|
||||
/* Unlock queue */
|
||||
sendQueueLock.unlock();
|
||||
|
||||
// TODO: Add libsnooze event wake up
|
||||
// TODO: Add a "register" function which can initialize pipes
|
||||
// ... without needing a wait, we'd need a ready flag though
|
||||
// ... for sender's thread start
|
||||
|
||||
/**
|
||||
* Wake up all threads waiting on this event
|
||||
* (if any, and if so it would only be the sender)
|
||||
*/
|
||||
sendEvent.notifyAll();
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +92,11 @@ public final class SenderThread : Thread
|
||||
|
||||
/* TODO: handle normal messages (xCount with fakeLagInBetween) */
|
||||
|
||||
// TODO: See above notes about libsnooze behaviour due
|
||||
// ... to usage in our context
|
||||
sendEvent.wait(); // TODO: Catch any exceptions from libsnooze
|
||||
|
||||
|
||||
/* Lock queue */
|
||||
sendQueueLock.lock();
|
||||
|
||||
@ -98,9 +111,13 @@ public final class SenderThread : Thread
|
||||
|
||||
/* Unlock queue */
|
||||
sendQueueLock.unlock();
|
||||
|
||||
/* TODO: Yield */
|
||||
Thread.yield();
|
||||
}
|
||||
}
|
||||
|
||||
public void end()
|
||||
{
|
||||
// TODO: See above notes about libsnooze behaviour due
|
||||
// ... to usage in our context
|
||||
sendEvent.notifyAll();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user