Source Code Cross Referenced for FIFOSemaphore.java in  » Ajax » Laszlo-4.0.10 » EDU » oswego » cs » dl » util » concurrent » 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 » Ajax » Laszlo 4.0.10 » EDU.oswego.cs.dl.util.concurrent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /*
02:          File: FIFOSemaphore.java
03:
04:          Originally written by Doug Lea and released into the public domain.
05:          This may be used for any purposes whatsoever without acknowledgment.
06:          Thanks for the assistance and support of Sun Microsystems Labs,
07:          and everyone contributing, testing, and using this code.
08:
09:          History:
10:          Date       Who                What
11:          11Jun1998  dl               Create public version
12:         */
13:
14:        package EDU.oswego.cs.dl.util.concurrent;
15:
16:        /** 
17:         * A First-in/First-out implementation of a Semaphore.
18:         * Waiting requests will be satisified in
19:         * the order that the processing of those requests got to a certain point.
20:         * If this sounds vague it is meant to be. FIFO implies a
21:         * logical timestamping at some point in the processing of the
22:         * request. To simplify things we don't actually timestamp but
23:         * simply store things in a FIFO queue. Thus the order in which
24:         * requests enter the queue will be the order in which they come
25:         * out.  This order need not have any relationship to the order in
26:         * which requests were made, nor the order in which requests
27:         * actually return to the caller. These depend on Java thread
28:         * scheduling which is not guaranteed to be predictable (although
29:         * JVMs tend not to go out of their way to be unfair). 
30:         * <p>[<a href="http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html"> Introduction to this package. </a>]
31:         **/
32:
33:        public class FIFOSemaphore extends QueuedSemaphore {
34:
35:            /** 
36:             * Create a Semaphore with the given initial number of permits.
37:             * Using a seed of one makes the semaphore act as a mutual exclusion lock.
38:             * Negative seeds are also allowed, in which case no acquires will proceed
39:             * until the number of releases has pushed the number of permits past 0.
40:             **/
41:
42:            public FIFOSemaphore(long initialPermits) {
43:                super (new FIFOWaitQueue(), initialPermits);
44:            }
45:
46:            /** 
47:             * Simple linked list queue used in FIFOSemaphore.
48:             * Methods are not synchronized; they depend on synch of callers
49:             **/
50:
51:            protected static class FIFOWaitQueue extends WaitQueue {
52:                protected WaitNode head_ = null;
53:                protected WaitNode tail_ = null;
54:
55:                protected void insert(WaitNode w) {
56:                    if (tail_ == null)
57:                        head_ = tail_ = w;
58:                    else {
59:                        tail_.next = w;
60:                        tail_ = w;
61:                    }
62:                }
63:
64:                protected WaitNode extract() {
65:                    if (head_ == null)
66:                        return null;
67:                    else {
68:                        WaitNode w = head_;
69:                        head_ = w.next;
70:                        if (head_ == null)
71:                            tail_ = null;
72:                        w.next = null;
73:                        return w;
74:                    }
75:                }
76:            }
77:
78:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.