[cvs] / jsr166 / src / main / java / util / concurrent / LinkedTransferQueue.java Repository:
ViewVC logotype

Diff of /jsr166/src/main/java/util/concurrent/LinkedTransferQueue.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37, Mon Nov 29 20:58:06 2010 UTC revision 1.38, Tue Feb 22 23:53:32 2011 UTC
# Line 496  Line 496 
496              return false;              return false;
497          }          }
498    
         // Unsafe mechanics  
         private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();  
         private static final long nextOffset =  
             objectFieldOffset(UNSAFE, "next", Node.class);  
         private static final long itemOffset =  
             objectFieldOffset(UNSAFE, "item", Node.class);  
         private static final long waiterOffset =  
             objectFieldOffset(UNSAFE, "waiter", Node.class);  
   
499          private static final long serialVersionUID = -3375979862319811754L;          private static final long serialVersionUID = -3375979862319811754L;
500    
501            // Unsafe mechanics
502            private static final sun.misc.Unsafe UNSAFE;
503            private static final long itemOffset;
504            private static final long nextOffset;
505            private static final long waiterOffset;
506            static {
507                try {
508                    UNSAFE = sun.misc.Unsafe.getUnsafe();
509                    Class k = Node.class;
510                    itemOffset = UNSAFE.objectFieldOffset
511                        (k.getDeclaredField("item"));
512                    nextOffset = UNSAFE.objectFieldOffset
513                        (k.getDeclaredField("next"));
514                    waiterOffset = UNSAFE.objectFieldOffset
515                        (k.getDeclaredField("waiter"));
516                } catch (Exception e) {
517                    throw new Error(e);
518                }
519            }
520      }      }
521    
522      /** head of the queue; null until first enqueue */      /** head of the queue; null until first enqueue */
# Line 1283  Line 1294 
1294    
1295      // Unsafe mechanics      // Unsafe mechanics
1296    
1297      private static final sun.misc.Unsafe UNSAFE = sun.misc.Unsafe.getUnsafe();      private static final sun.misc.Unsafe UNSAFE;
1298      private static final long headOffset =      private static final long headOffset;
1299          objectFieldOffset(UNSAFE, "head", LinkedTransferQueue.class);      private static final long tailOffset;
1300      private static final long tailOffset =      private static final long sweepVotesOffset;
1301          objectFieldOffset(UNSAFE, "tail", LinkedTransferQueue.class);      static {
     private static final long sweepVotesOffset =  
         objectFieldOffset(UNSAFE, "sweepVotes", LinkedTransferQueue.class);  
   
     static long objectFieldOffset(sun.misc.Unsafe UNSAFE,  
                                   String field, Class<?> klazz) {  
1302          try {          try {
1303              return UNSAFE.objectFieldOffset(klazz.getDeclaredField(field));              UNSAFE = sun.misc.Unsafe.getUnsafe();
1304          } catch (NoSuchFieldException e) {              Class k = LinkedTransferQueue.class;
1305              // Convert Exception to corresponding Error              headOffset = UNSAFE.objectFieldOffset
1306              NoSuchFieldError error = new NoSuchFieldError(field);                  (k.getDeclaredField("head"));
1307              error.initCause(e);              tailOffset = UNSAFE.objectFieldOffset
1308              throw error;                  (k.getDeclaredField("tail"));
1309                sweepVotesOffset = UNSAFE.objectFieldOffset
1310                    (k.getDeclaredField("sweepVotes"));
1311            } catch (Exception e) {
1312                throw new Error(e);
1313          }          }
1314      }      }
1315  }  }

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.38

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8