Source Code Cross Referenced for Atomics.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » 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 » Apache Harmony Java SE » org package » org.apache.harmony.util.concurrent 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Artem A. Aliev, Andrey Y. Chernyshev, Sergey V. Dmitriev
019:         * @version $Revision: 1.1.6.3 $
020:         */package org.apache.harmony.util.concurrent;
021:
022:        import java.lang.reflect.Field;
023:
024:        /**
025:         * Allows to atomically update the contents of fields for the specific object. The primary purpose
026:         * of this class is to provide the low-level atomic field access operations useful for
027:         * implementing the classes from java.util.concurrent.atomic package.
028:         *
029:         * @see java.util.concurrent.atomic
030:         */
031:        public final class Atomics {
032:
033:            private Atomics() {
034:            };
035:
036:            /**
037:             * Returns offset of the first array's element 
038:             * @param arrayClass class of the array
039:             *
040:             * @return offset of the array's first element
041:             */
042:            public static native int arrayBaseOffset(Class arrayClass);
043:
044:            /**
045:             * Returns size of the array's element
046:             * @param arrayClass class of the array
047:             *
048:             * @return size of the array's element
049:             */
050:            public static native int arrayIndexScale(Class arrayClass);
051:
052:            /*
053:             * Writes new value to the object's field (by given offset) in volatile manner
054:             * @param obj object which field needs to be set
055:             * @param offset the field offset within the given object
056:             * @param value value to set
057:             */
058:            public static native void setIntVolatile(Object obj, long offset,
059:                    int value);
060:
061:            /*
062:             * Reads value from the object's field (by given offset) in volatile manner
063:             * @param obj object which field needs to be read
064:             * @param offset the field offset within the given object
065:             * @return the field's value
066:             */
067:            public static native int getIntVolatile(Object obj, long offset);
068:
069:            /*
070:             * Writes new value to the object's field (by given offset) in volatile manner
071:             * @param obj object which field needs to be set
072:             * @param offset the field offset within the given object
073:             * @param value value to set
074:             */
075:            public static native void setLongVolatile(Object obj, long offset,
076:                    long value);
077:
078:            /*
079:             * Reads value from the object's field (by given offset) in volatile manner
080:             * @param obj object which field needs to be read
081:             * @param offset the field offset within the given object
082:             * @return the field's value
083:             */
084:            public static native long getLongVolatile(Object obj, long offset);
085:
086:            /*
087:             * Writes new value to the object's field (by given offset) in volatile manner
088:             * @param obj object which field needs to be set
089:             * @param offset the field offset within the given object
090:             * @param value value to set
091:             */
092:            public static native void setObjectVolatile(Object obj,
093:                    long offset, Object value);
094:
095:            /*
096:             * Reads value from the object's field (by given offset) in volatile manner
097:             * @param obj object which field needs to be read
098:             * @param offset the field offset within the given object
099:             * @return the field's value
100:             */
101:            public static native Object getObjectVolatile(Object obj,
102:                    long offset);
103:
104:            /**
105:             * Returns offset of the given field.
106:             * @param field the field for which offset is returned
107:             *
108:             * @return offset of the given field
109:             */
110:            public static native long getFieldOffset(Field field);
111:
112:            /**
113:             * Atomically sets an integer field to x if it currently contains the expected value.
114:             * @param o object those integer field needs to be set
115:             * @param field the field to be set
116:             * @param expected expected field value
117:             * @param x value to set.
118:             *
119:             * @return true if the value was set.
120:             * False return indicates that the actual value was not equal to the expected value.
121:             */
122:            public static native boolean compareAndSetInt(Object o,
123:                    long offset, int expected, int x);
124:
125:            /**
126:             * Atomically sets a boolean field to x if it currently contains the expected value.
127:             * @param o object those boolean field needs to be set
128:             * @param field the field to be set
129:             * @param expected expected field value
130:             * @param x value to set.
131:             *
132:             * @return true if the value was set.
133:             * False return indicates that the actual value was not equal to the expected value.
134:             */
135:            public static native boolean compareAndSetBoolean(Object o,
136:                    long offset, boolean expected, boolean x);
137:
138:            /**
139:             * Atomically sets a long field to x if it currently contains the expected value.
140:             * @param o object those long field needs to be set
141:             * @param field the field to be set
142:             * @param expected expected field value
143:             * @param x value to set.
144:             *
145:             * @return true if the value was set.
146:             * False return indicates that the actual value was not equal to the expected value.
147:             */
148:            public static native boolean compareAndSetLong(Object o,
149:                    long offset, long expected, long x);
150:
151:            /**
152:             * Atomically sets a reference type field to x if it currently contains the expected value.
153:             * @param o object those reference type field needs to be set
154:             * @param field the field to be set
155:             * @param expected expected field value
156:             * @param x value to set.
157:             *
158:             * @return true if the value was set.
159:             * False return indicates that the actual value was not equal to the expected value.
160:             */
161:            public static native boolean compareAndSetObject(Object o,
162:                    long offset, Object expected, Object x);
163:
164:            /**
165:             * Atomically sets an element within array of integers to x if it currently contains the expected value.
166:             * @param arr array those integer element needs to be set
167:             * @param index an index within an array
168:             * @param expected expected field value
169:             * @param x value to set.
170:             *
171:             * @return true if the value was set.
172:             * False return indicates that the actual value was not equal to the expected value.
173:             */
174:            public static native boolean compareAndSetInt(int[] arr, int index,
175:                    int expected, int x);
176:
177:            /**
178:             * Atomically sets an element within array of booleans to x if it currently contains the expected value.
179:             * @param arr array those boolean element needs to be set
180:             * @param index an index within an array
181:             * @param expected expected field value
182:             * @param x value to set.
183:             *
184:             * @return true if the value was set.
185:             * False return indicates that the actual value was not equal to the expected value.
186:             */
187:            public static native boolean compareAndSetBoolean(boolean[] arr,
188:                    int index, boolean expected, boolean x);
189:
190:            /**
191:             * Atomically sets an element within array of longs to x if it currently contains the expected value.
192:             * @param arr array those long element needs to be set
193:             * @param index an index within an array
194:             * @param expected expected field value
195:             * @param x value to set.
196:             *
197:             * @return true if the value was set.
198:             * False return indicates that the actual value was not equal to the expected value.
199:             */
200:            public static native boolean compareAndSetLong(long[] arr,
201:                    int index, long expected, long x);
202:
203:            /**
204:             * Atomically sets an element within array of objects to x if it currently contains the expected value.
205:             * @param arr array those object element needs to be set
206:             * @param index an index within an array
207:             * @param expected expected field value
208:             * @param x value to set.
209:             *
210:             * @return true if the value was set.
211:             * False return indicates that the actual value was not equal to the expected value.
212:             */
213:            public static native boolean compareAndSetObject(Object[] arr,
214:                    int index, Object expected, Object x);
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.