src/share/vm/runtime/objectMonitor.hpp

Print this page


   1 /*
   2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 300     _SpinFreq      = 0;
 301     _SpinClock     = 0;
 302   }
 303 
 304  public:
 305 
 306   void*     object() const;
 307   void*     object_addr();
 308   void      set_object(void* obj);
 309 
 310   bool      check(TRAPS);       // true if the thread owns the monitor.
 311   void      check_slow(TRAPS);
 312   void      clear();
 313   static void sanity_checks();  // public for -XX:+ExecuteInternalVMTests
 314                                 // in PRODUCT for -XX:SyncKnobs=Verbose=1
 315 #ifndef PRODUCT
 316   void      verify();
 317   void      print();
 318 #endif
 319 
 320   bool      try_enter(TRAPS);
 321   void      enter(TRAPS);
 322   void      exit(bool not_suspended, TRAPS);
 323   void      wait(jlong millis, bool interruptable, TRAPS);
 324   void      notify(TRAPS);
 325   void      notifyAll(TRAPS);
 326 
 327 // Use the following at your own risk
 328   intptr_t  complete_exit(TRAPS);
 329   void      reenter(intptr_t recursions, TRAPS);
 330 
 331  private:
 332   void      AddWaiter(ObjectWaiter * waiter);
 333   static    void DeferredInitialize();
 334 
 335   ObjectWaiter * DequeueWaiter();
 336   void      DequeueSpecificWaiter(ObjectWaiter * waiter);
 337   void      EnterI(TRAPS);
 338   void      ReenterI(Thread * Self, ObjectWaiter * SelfNode);
 339   void      UnlinkAfterAcquire(Thread * Self, ObjectWaiter * SelfNode);
 340   int       TryLock(Thread * Self);


   1 /*
   2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


 300     _SpinFreq      = 0;
 301     _SpinClock     = 0;
 302   }
 303 
 304  public:
 305 
 306   void*     object() const;
 307   void*     object_addr();
 308   void      set_object(void* obj);
 309 
 310   bool      check(TRAPS);       // true if the thread owns the monitor.
 311   void      check_slow(TRAPS);
 312   void      clear();
 313   static void sanity_checks();  // public for -XX:+ExecuteInternalVMTests
 314                                 // in PRODUCT for -XX:SyncKnobs=Verbose=1
 315 #ifndef PRODUCT
 316   void      verify();
 317   void      print();
 318 #endif
 319 

 320   void      enter(TRAPS);
 321   void      exit(bool not_suspended, TRAPS);
 322   void      wait(jlong millis, bool interruptable, TRAPS);
 323   void      notify(TRAPS);
 324   void      notifyAll(TRAPS);
 325 
 326 // Use the following at your own risk
 327   intptr_t  complete_exit(TRAPS);
 328   void      reenter(intptr_t recursions, TRAPS);
 329 
 330  private:
 331   void      AddWaiter(ObjectWaiter * waiter);
 332   static    void DeferredInitialize();
 333 
 334   ObjectWaiter * DequeueWaiter();
 335   void      DequeueSpecificWaiter(ObjectWaiter * waiter);
 336   void      EnterI(TRAPS);
 337   void      ReenterI(Thread * Self, ObjectWaiter * SelfNode);
 338   void      UnlinkAfterAcquire(Thread * Self, ObjectWaiter * SelfNode);
 339   int       TryLock(Thread * Self);