Java Doc for Queue2.java in  » Net » JGroups-2.4.1-sp3 » org » jgroups » util » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » JGroups 2.4.1 sp3 » org.jgroups.util 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jgroups.util.Queue2

Queue2
public class Queue2 (Code)
Elements are added at the tail and removed from the head. Class is thread-safe in that 1 producer and 1 consumer may add/remove elements concurrently. The class is not explicitely designed for multiple producers or consumers. Implemented as a linked list, so that removal of an element at the head does not cause a right-shift of the remaining elements (as in a Vector-based implementation).

Implementation is based on util.concurrent.* classes
author:
   Bela Ban
author:
   Filip Hanik


Inner Class :class Element

Field Summary
final  CondVaradd_condvar
    
 booleanclosed
    
 Elementheadtail
    
final protected static  Loglog
    
final  Syncmutex
    
 intnum_markers
    
final  CondVarremove_condvar
    
 intsize
    

Constructor Summary
public  Queue2()
    

Method Summary
public  voidadd(Object obj)
     adds an object to the tail of this queue If the queue has been closed with close(true) no exception will be thrown if the queue has not been flushed yet.
public  voidaddAtHead(Object obj)
     Adds a new object to the head of the queue basically (obj.equals(queue.remove(queue.add(obj)))) returns true If the queue has been closed with close(true) no exception will be thrown if the queue has not been flushed yet.
public  voidclose(boolean flush_entries)
     Marks the queues as closed.
public  booleanclosed()
     returns true if the Queue has been closed however, this method will return false if the queue has been closed using the close(true) method and the last element has yet not been received.
public  Stringdebug()
    
 voiddecrementSize()
    
public  VectorgetContents()
    
public  ObjectgetFirst()
     Returns the first element.
public  ObjectgetLast()
     Returns the last element.
public  Objectpeek()
     returns the first object on the queue, without removing it.
public  Objectpeek(long timeout)
     returns the first object on the queue, without removing it.
public  Objectremove()
    
public  Objectremove(long timeout)
     Removes 1 element from the head.
public  voidremoveElement(Object obj)
     removes a specific object from the queue.
public  voidreset()
     resets the queue.
public  intsize()
    
public  StringtoString()
    
public  voidwaitUntilEmpty(long timeout)
     Blocks until the queue has no elements left.

Field Detail
add_condvar
final CondVar add_condvar(Code)
Signals to listeners when an element has been added



closed
boolean closed(Code)



headtail
Element headtail(Code)



log
final protected static Log log(Code)



mutex
final Sync mutex(Code)



num_markers
int num_markers(Code)



remove_condvar
final CondVar remove_condvar(Code)
Signals to listeners when an element has been removed



size
int size(Code)




Constructor Detail
Queue2
public Queue2()(Code)
creates an empty queue




Method Detail
add
public void add(Object obj) throws QueueClosedException(Code)
adds an object to the tail of this queue If the queue has been closed with close(true) no exception will be thrown if the queue has not been flushed yet.
Parameters:
  obj - - the object to be added to the queue
exception:
  QueueClosedException - exception if closed() returns true



addAtHead
public void addAtHead(Object obj) throws QueueClosedException(Code)
Adds a new object to the head of the queue basically (obj.equals(queue.remove(queue.add(obj)))) returns true If the queue has been closed with close(true) no exception will be thrown if the queue has not been flushed yet.
Parameters:
  obj - - the object to be added to the queue
exception:
  QueueClosedException - exception if closed() returns true



close
public void close(boolean flush_entries)(Code)
Marks the queues as closed. When an add or remove operation is attempted on a closed queue, an exception is thrown.
Parameters:
  flush_entries - When true, a end-of-entries marker is added to the end of the queue.Entries may be added and removed, but when the end-of-entries markeris encountered, the queue is marked as closed. This allows to flushpending messages before closing the queue.



closed
public boolean closed()(Code)
returns true if the Queue has been closed however, this method will return false if the queue has been closed using the close(true) method and the last element has yet not been received. true if the queue has been closed



debug
public String debug()(Code)
Dumps internal state @remove



decrementSize
void decrementSize()(Code)



getContents
public Vector getContents()(Code)
returns a vector with all the objects currently in the queue



getFirst
public Object getFirst()(Code)
Returns the first element. Returns null if no elements are available.



getLast
public Object getLast()(Code)
Returns the last element. Returns null if no elements are available.



peek
public Object peek() throws QueueClosedException(Code)
returns the first object on the queue, without removing it. If the queue is empty this object blocks until the first queue object has been added the first object on the queue



peek
public Object peek(long timeout) throws QueueClosedException, TimeoutException(Code)
returns the first object on the queue, without removing it. If the queue is empty this object blocks until the first queue object has been added or the operation times out
Parameters:
  timeout - how long in milli seconds will this operation wait for an object to be added to the queuebefore it times out the first object on the queue



remove
public Object remove() throws QueueClosedException(Code)
Removes 1 element from head or blocks until next element has been added or until queue has been closed the first element to be taken of the queue



remove
public Object remove(long timeout) throws QueueClosedException, TimeoutException(Code)
Removes 1 element from the head. If the queue is empty the operation will wait for timeout ms. if no object is added during the timeout time, a Timout exception is thrown
Parameters:
  timeout - - the number of milli seconds this operation will wait before it times out the first object in the queue



removeElement
public void removeElement(Object obj) throws QueueClosedException(Code)
removes a specific object from the queue. the object is matched up using the Object.equals method.
Parameters:
  obj - the actual object to be removed from the queue



reset
public void reset()(Code)
resets the queue. This operation removes all the objects in the queue and marks the queue open



size
public int size()(Code)
returns the number of objects that are currently in the queue



toString
public String toString()(Code)
prints the size of the queue



waitUntilEmpty
public void waitUntilEmpty(long timeout) throws QueueClosedException, TimeoutException(Code)
Blocks until the queue has no elements left. If the queue is empty, the call will return immediately
Parameters:
  timeout - Call returns if timeout has elapsed (number of milliseconds). 0 means to wait forever
throws:
  QueueClosedException - Thrown if queue has been closed
throws:
  TimeoutException - Thrown if timeout has elapsed



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.