131
132 enum SafepointCheckRequired {
133 _safepoint_check_never, // Mutexes with this value will cause errors
134 // when acquired by a JavaThread with a safepoint check.
135 _safepoint_check_sometimes, // A couple of special locks are acquired by JavaThreads sometimes
136 // with and sometimes without safepoint checks. These
137 // locks will not produce errors when locked.
138 _safepoint_check_always // Mutexes with this value will cause errors
139 // when acquired by a JavaThread without a safepoint check.
140 };
141
142 NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;)
143
144 public:
145 Mutex(int rank, const char *name, bool allow_vm_block = false,
146 SafepointCheckRequired safepoint_check_required = _safepoint_check_always);
147 ~Mutex();
148
149 void lock(); // prints out warning if VM thread blocks
150 void lock(Thread *thread); // overloaded with current thread
151 void unlock();
152 bool is_locked() const { return _owner != NULL; }
153
154 bool try_lock(); // Like lock(), but unblocking. It returns false instead
155
156 void release_for_safepoint();
157
158 // Lock without safepoint check. Should ONLY be used by safepoint code and other code
159 // that is guaranteed not to block while running inside the VM.
160 void lock_without_safepoint_check();
161 void lock_without_safepoint_check(Thread* self);
162
163 // Current owner - not not MT-safe. Can only be used to guarantee that
164 // the current running thread owns the lock
165 Thread* owner() const { return _owner; }
166 bool owned_by_self() const;
167
168 const char *name() const { return _name; }
169
170 void print_on_error(outputStream* st) const;
171
172 #ifndef PRODUCT
173 void print_on(outputStream* st) const;
174 void print() const { print_on(::tty); }
175 #endif
176 #ifdef ASSERT
177 int rank() const { return _rank; }
178 bool allow_vm_block() { return _allow_vm_block; }
179
180 Mutex *next() const { return _next; }
181 void set_next(Mutex *next) { _next = next; }
|
131
132 enum SafepointCheckRequired {
133 _safepoint_check_never, // Mutexes with this value will cause errors
134 // when acquired by a JavaThread with a safepoint check.
135 _safepoint_check_sometimes, // A couple of special locks are acquired by JavaThreads sometimes
136 // with and sometimes without safepoint checks. These
137 // locks will not produce errors when locked.
138 _safepoint_check_always // Mutexes with this value will cause errors
139 // when acquired by a JavaThread without a safepoint check.
140 };
141
142 NOT_PRODUCT(SafepointCheckRequired _safepoint_check_required;)
143
144 public:
145 Mutex(int rank, const char *name, bool allow_vm_block = false,
146 SafepointCheckRequired safepoint_check_required = _safepoint_check_always);
147 ~Mutex();
148
149 void lock(); // prints out warning if VM thread blocks
150 void lock(Thread *thread); // overloaded with current thread
151
152 void lock_slow(Thread* self);
153
154 bool try_lock(); // Like lock(), but unblocking. It returns false instead
155 bool try_lock(Thread *thread); // overloaded with current thread
156
157 // Lock without safepoint check. Should ONLY be used by safepoint code and other code
158 // that is guaranteed not to block while running inside the VM.
159 void lock_without_safepoint_check();
160 void lock_without_safepoint_check(Thread* self);
161
162 void unlock();
163
164 bool is_locked() const { return _owner != NULL; }
165
166 void release_for_safepoint();
167
168 // Current owner - not not MT-safe. Can only be used to guarantee that
169 // the current running thread owns the lock
170 Thread* owner() const { return _owner; }
171 bool owned_by_self() const;
172
173 const char *name() const { return _name; }
174
175 void print_on_error(outputStream* st) const;
176
177 #ifndef PRODUCT
178 void print_on(outputStream* st) const;
179 void print() const { print_on(::tty); }
180 #endif
181 #ifdef ASSERT
182 int rank() const { return _rank; }
183 bool allow_vm_block() { return _allow_vm_block; }
184
185 Mutex *next() const { return _next; }
186 void set_next(Mutex *next) { _next = next; }
|