Debugging output
This commit is contained in:
parent
6a88b3fa56
commit
49ec551e69
1 changed files with 9 additions and 3 deletions
|
@ -10,12 +10,16 @@ public abstract class ActorThread<M> extends Thread {
|
||||||
|
|
||||||
/** Called by another thread, to send a message to this thread. */
|
/** Called by another thread, to send a message to this thread. */
|
||||||
public void send(M message) {
|
public void send(M message) {
|
||||||
|
System.out.println(" # Sending message: " + message);
|
||||||
q.offer(message);
|
q.offer(message);
|
||||||
|
System.out.println(" % Queue State: " + q);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the first message in the queue, or blocks if none available. */
|
/** Returns the first message in the queue, or blocks if none available. */
|
||||||
protected M receive() throws InterruptedException {
|
protected M receive() throws InterruptedException {
|
||||||
return q.take();
|
M mess = q.take();
|
||||||
|
System.out.println(" - Message taken: " + mess);
|
||||||
|
return mess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the first message in the queue, or blocks up to 'timeout'
|
/** Returns the first message in the queue, or blocks up to 'timeout'
|
||||||
|
@ -27,7 +31,9 @@ public abstract class ActorThread<M> extends Thread {
|
||||||
|
|
||||||
protected Optional<M> poll(long timeOut) {
|
protected Optional<M> poll(long timeOut) {
|
||||||
try {
|
try {
|
||||||
return Optional.ofNullable(q.poll(timeOut, TimeUnit.MILLISECONDS));
|
Optional<M> m = Optional.ofNullable(q.poll(timeOut, TimeUnit.MILLISECONDS));
|
||||||
|
System.out.println("Stolen: " + m);
|
||||||
|
return m;
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
Loading…
Reference in a new issue