org.codehaus.gpars

groovyx.gpars.util
[Java] Class DefaultMessageQueue

java.lang.Object
  groovyx.gpars.util.DefaultMessageQueue
All Implemented Interfaces:
MessageQueue

@java.lang.SuppressWarningsreturn inside.removeFirst();
public final class DefaultMessageQueue

An implementation of the message queue for actor and agent messaging. It leverages the fact that in any moment there's only one reading thread accessing the queue and that potential read thread swap at the actor or agent thread pool synchronizes thread memory.

We also count on writers not to call the isEmpty() method

Authors:
Vaclav Pech


Field Summary
private boolean empty

private java.util.LinkedList inside

private java.util.LinkedList outside

 
Constructor Summary
DefaultMessageQueue()

 
Method Summary
void add(java.lang.Object element)

boolean isEmpty()

java.lang.Object poll()

private void swap(java.util.LinkedList localQueue)

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

empty

private boolean empty


inside

private java.util.LinkedList inside


outside

private java.util.LinkedList outside


 
Constructor Detail

DefaultMessageQueue

DefaultMessageQueue()


 
Method Detail

add

@java.lang.Override
public void add(java.lang.Object element)


isEmpty

@java.lang.Override}
public boolean isEmpty()


poll

@java.lang.Overrideoutside = localQueue;
public java.lang.Object poll()


swap

private void swap(java.util.LinkedList localQueue)


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.