< prev index next >

src/hotspot/share/services/mallocSiteTable.hpp

Print this page




 136     // A very large negative number. The only possibility to "overflow"
 137     // this number is when there are more than -min_jint threads in
 138     // this process, which is not going to happen in foreseeable future.
 139     const static int _MAGIC_ = min_jint;
 140 
 141     LockState      _lock_state;
 142     volatile int*  _lock;
 143    public:
 144     AccessLock(volatile int* lock) :
 145       _lock_state(NoLock), _lock(lock) {
 146     }
 147 
 148     ~AccessLock() {
 149       if (_lock_state == SharedLock) {
 150         Atomic::dec(_lock);
 151       }
 152     }
 153     // Acquire shared lock.
 154     // Return true if shared access is granted.
 155     inline bool sharedLock() {
 156       jint res = Atomic::add(1, _lock);
 157       if (res < 0) {
 158         Atomic::dec(_lock);
 159         return false;
 160       }
 161       _lock_state = SharedLock;
 162       return true;
 163     }
 164     // Acquire exclusive lock
 165     void exclusiveLock();
 166  };
 167 
 168  public:
 169   static bool initialize();
 170   static void shutdown();
 171 
 172   NOT_PRODUCT(static int access_peak_count() { return _peak_count; })
 173 
 174   // Number of hash buckets
 175   static inline int hash_buckets()      { return (int)table_size; }
 176 




 136     // A very large negative number. The only possibility to "overflow"
 137     // this number is when there are more than -min_jint threads in
 138     // this process, which is not going to happen in foreseeable future.
 139     const static int _MAGIC_ = min_jint;
 140 
 141     LockState      _lock_state;
 142     volatile int*  _lock;
 143    public:
 144     AccessLock(volatile int* lock) :
 145       _lock_state(NoLock), _lock(lock) {
 146     }
 147 
 148     ~AccessLock() {
 149       if (_lock_state == SharedLock) {
 150         Atomic::dec(_lock);
 151       }
 152     }
 153     // Acquire shared lock.
 154     // Return true if shared access is granted.
 155     inline bool sharedLock() {
 156       jint res = Atomic::add(_lock, 1);
 157       if (res < 0) {
 158         Atomic::dec(_lock);
 159         return false;
 160       }
 161       _lock_state = SharedLock;
 162       return true;
 163     }
 164     // Acquire exclusive lock
 165     void exclusiveLock();
 166  };
 167 
 168  public:
 169   static bool initialize();
 170   static void shutdown();
 171 
 172   NOT_PRODUCT(static int access_peak_count() { return _peak_count; })
 173 
 174   // Number of hash buckets
 175   static inline int hash_buckets()      { return (int)table_size; }
 176 


< prev index next >