SunSPOT API V3.0


com.sun.spot.util
Class Queue

java.lang.Object
  extended by com.sun.spot.util.Queue

public class Queue
extends Object

Implements a fully synchronised FIFO queue of Objects.


Constructor Summary
Queue()
           
 
Method Summary
 void empty()
          Drop the contents of the queue.
 Object get()
          Answer an element from the receiver.
 Object get(long timeout)
          Answer an element from the receiver.
 boolean isEmpty()
          Answer whether the receiver is empty.
 void put(Object o)
          Add an element to the receiver.
 int size()
          Answer the number of elements in the receiver.
 void stop()
          Release all waiters
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Method Detail

isEmpty

public boolean isEmpty()
Answer whether the receiver is empty.

Returns:
- whether the receiver is empty.

size

public int size()
Answer the number of elements in the receiver.

Returns:
-- the number of elements in the receiver.

put

public void put(Object o)
Add an element to the receiver.

Parameters:
o - -- the Object to add

get

public Object get(long timeout)
Answer an element from the receiver. If the receiver is empty, block until either an element becomes available, or for timeout milliseconds, or the queue is stopped. In the event of timeout, return null. Note that if a waiting thread is interrupted it will return (probably null).

Parameters:
timeout - -- number of milliseconds to wait
Returns:
-- either the first element from the receiver or null after a timeout or if queue is stopped.

get

public Object get()
Answer an element from the receiver. If the receiver is empty, block (possibly forever) until an element becomes available. Note that if a waiting thread is interrupted it will return (probably null).

Returns:
-- the first element from the receiver, or null if queue is stopped

stop

public void stop()
Release all waiters


empty

public void empty()
Drop the contents of the queue.


SunSPOT API V3.0


Copyright © 2006, 2007 Sun Microsystems, Inc. All Rights Reserved.