src/share/vm/prims/jvmtiRawMonitor.hpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2007, 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  *
  23  */
  24 








  25 //
  26 // class JvmtiRawMonitor
  27 //
  28 // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
  29 //
  30 // Wrapper for ObjectMonitor class that saves the Monitor's name
  31 //
  32 
  33 class JvmtiRawMonitor : public ObjectMonitor  {
  34 private:
  35   int           _magic;
  36   char *        _name;
  37   // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
  38   enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
  39 
  40   int       SimpleEnter (Thread * Self) ;
  41   int       SimpleExit  (Thread * Self) ;
  42   int       SimpleWait  (Thread * Self, jlong millis) ;
  43   int       SimpleNotify (Thread * Self, bool All) ;
  44 


  80   }
  81 
  82   static void destroy(JvmtiRawMonitor *monitor) {
  83     while (monitors()->contains(monitor)) {
  84       monitors()->remove(monitor);
  85     }
  86   }
  87 
  88   // Return false if monitor is not found in the list.
  89   static bool exit(JvmtiRawMonitor *monitor) {
  90     if (monitors()->contains(monitor)) {
  91       monitors()->remove(monitor);
  92       return true;
  93     } else {
  94       return false;
  95     }
  96   }
  97 
  98   static void transition_raw_monitors();
  99 };


   1 /*
   2  * Copyright (c) 1999, 2010, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
  26 #define SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP
  27 
  28 #ifndef JVMTI_KERNEL
  29 #include "runtime/objectMonitor.hpp"
  30 #include "utilities/growableArray.hpp"
  31 #endif
  32 
  33 //
  34 // class JvmtiRawMonitor
  35 //
  36 // Used by JVMTI methods: All RawMonitor methods (CreateRawMonitor, EnterRawMonitor, etc.)
  37 //
  38 // Wrapper for ObjectMonitor class that saves the Monitor's name
  39 //
  40 
  41 class JvmtiRawMonitor : public ObjectMonitor  {
  42 private:
  43   int           _magic;
  44   char *        _name;
  45   // JVMTI_RM_MAGIC is set in contructor and unset in destructor.
  46   enum { JVMTI_RM_MAGIC = (int)(('T' << 24) | ('I' << 16) | ('R' << 8) | 'M') };
  47 
  48   int       SimpleEnter (Thread * Self) ;
  49   int       SimpleExit  (Thread * Self) ;
  50   int       SimpleWait  (Thread * Self, jlong millis) ;
  51   int       SimpleNotify (Thread * Self, bool All) ;
  52 


  88   }
  89 
  90   static void destroy(JvmtiRawMonitor *monitor) {
  91     while (monitors()->contains(monitor)) {
  92       monitors()->remove(monitor);
  93     }
  94   }
  95 
  96   // Return false if monitor is not found in the list.
  97   static bool exit(JvmtiRawMonitor *monitor) {
  98     if (monitors()->contains(monitor)) {
  99       monitors()->remove(monitor);
 100       return true;
 101     } else {
 102       return false;
 103     }
 104   }
 105 
 106   static void transition_raw_monitors();
 107 };
 108 
 109 #endif // SHARE_VM_PRIMS_JVMTIRAWMONITOR_HPP