314 virtual bool is_Java_thread() const { return false; }
315 virtual bool is_Compiler_thread() const { return false; }
316 virtual bool is_hidden_from_external_view() const { return false; }
317 virtual bool is_jvmti_agent_thread() const { return false; }
318 // True iff the thread can perform GC operations at a safepoint.
319 // Generally will be true only of VM thread and parallel GC WorkGang
320 // threads.
321 virtual bool is_GC_task_thread() const { return false; }
322 virtual bool is_Watcher_thread() const { return false; }
323 virtual bool is_ConcurrentGC_thread() const { return false; }
324 virtual bool is_Named_thread() const { return false; }
325 virtual bool is_Worker_thread() const { return false; }
326
327 // Casts
328 virtual WorkerThread* as_Worker_thread() const { return NULL; }
329
330 virtual char* name() const { return (char*)"Unknown thread"; }
331
332 // Returns the current thread
333 static inline Thread* current();
334
335 // Common thread operations
336 static void set_priority(Thread* thread, ThreadPriority priority);
337 static ThreadPriority get_priority(const Thread* const thread);
338 static void start(Thread* thread);
339 static void interrupt(Thread* thr);
340 static bool is_interrupted(Thread* thr, bool clear_interrupted);
341
342 void set_native_thread_name(const char *name) {
343 assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
344 os::set_native_thread_name(name);
345 }
346
347 ObjectMonitor** omInUseList_addr() { return (ObjectMonitor **)&omInUseList; }
348 Monitor* SR_lock() const { return _SR_lock; }
349
350 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
351
352 void set_suspend_flag(SuspendFlags f) {
353 assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
664 // Inline implementation of Thread::current()
665 // Thread::current is "hot" it's called > 128K times in the 1st 500 msecs of
666 // startup.
667 // ThreadLocalStorage::thread is warm -- it's called > 16K times in the same
668 // period. This is inlined in thread_<os_family>.inline.hpp.
669
670 inline Thread* Thread::current() {
671 #ifdef ASSERT
672 // This function is very high traffic. Define PARANOID to enable expensive
673 // asserts.
674 #ifdef PARANOID
675 // Signal handler should call ThreadLocalStorage::get_thread_slow()
676 Thread* t = ThreadLocalStorage::get_thread_slow();
677 assert(t != NULL && !t->is_inside_signal_handler(),
678 "Don't use Thread::current() inside signal handler");
679 #endif
680 #endif
681 Thread* thread = ThreadLocalStorage::thread();
682 assert(thread != NULL, "just checking");
683 return thread;
684 }
685
686 // Name support for threads. non-JavaThread subclasses with multiple
687 // uniquely named instances should derive from this.
688 class NamedThread: public Thread {
689 friend class VMStructs;
690 enum {
691 max_name_len = 64
692 };
693 private:
694 char* _name;
695 // log JavaThread being processed by oops_do
696 JavaThread* _processed_thread;
697
698 public:
699 NamedThread();
700 ~NamedThread();
701 // May only be called once per thread.
702 void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
703 virtual bool is_Named_thread() const { return true; }
|
314 virtual bool is_Java_thread() const { return false; }
315 virtual bool is_Compiler_thread() const { return false; }
316 virtual bool is_hidden_from_external_view() const { return false; }
317 virtual bool is_jvmti_agent_thread() const { return false; }
318 // True iff the thread can perform GC operations at a safepoint.
319 // Generally will be true only of VM thread and parallel GC WorkGang
320 // threads.
321 virtual bool is_GC_task_thread() const { return false; }
322 virtual bool is_Watcher_thread() const { return false; }
323 virtual bool is_ConcurrentGC_thread() const { return false; }
324 virtual bool is_Named_thread() const { return false; }
325 virtual bool is_Worker_thread() const { return false; }
326
327 // Casts
328 virtual WorkerThread* as_Worker_thread() const { return NULL; }
329
330 virtual char* name() const { return (char*)"Unknown thread"; }
331
332 // Returns the current thread
333 static inline Thread* current();
334 static inline Thread* current_or_null();
335
336 // Common thread operations
337 static void set_priority(Thread* thread, ThreadPriority priority);
338 static ThreadPriority get_priority(const Thread* const thread);
339 static void start(Thread* thread);
340 static void interrupt(Thread* thr);
341 static bool is_interrupted(Thread* thr, bool clear_interrupted);
342
343 void set_native_thread_name(const char *name) {
344 assert(Thread::current() == this, "set_native_thread_name can only be called on the current thread");
345 os::set_native_thread_name(name);
346 }
347
348 ObjectMonitor** omInUseList_addr() { return (ObjectMonitor **)&omInUseList; }
349 Monitor* SR_lock() const { return _SR_lock; }
350
351 bool has_async_exception() const { return (_suspend_flags & _has_async_exception) != 0; }
352
353 void set_suspend_flag(SuspendFlags f) {
354 assert(sizeof(jint) == sizeof(_suspend_flags), "size mismatch");
665 // Inline implementation of Thread::current()
666 // Thread::current is "hot" it's called > 128K times in the 1st 500 msecs of
667 // startup.
668 // ThreadLocalStorage::thread is warm -- it's called > 16K times in the same
669 // period. This is inlined in thread_<os_family>.inline.hpp.
670
671 inline Thread* Thread::current() {
672 #ifdef ASSERT
673 // This function is very high traffic. Define PARANOID to enable expensive
674 // asserts.
675 #ifdef PARANOID
676 // Signal handler should call ThreadLocalStorage::get_thread_slow()
677 Thread* t = ThreadLocalStorage::get_thread_slow();
678 assert(t != NULL && !t->is_inside_signal_handler(),
679 "Don't use Thread::current() inside signal handler");
680 #endif
681 #endif
682 Thread* thread = ThreadLocalStorage::thread();
683 assert(thread != NULL, "just checking");
684 return thread;
685 }
686
687 inline Thread* Thread::current_or_null() {
688 if (ThreadLocalStorage::is_initialized()) {
689 return ThreadLocalStorage::thread();
690 }
691 return NULL;
692 }
693
694 // Name support for threads. non-JavaThread subclasses with multiple
695 // uniquely named instances should derive from this.
696 class NamedThread: public Thread {
697 friend class VMStructs;
698 enum {
699 max_name_len = 64
700 };
701 private:
702 char* _name;
703 // log JavaThread being processed by oops_do
704 JavaThread* _processed_thread;
705
706 public:
707 NamedThread();
708 ~NamedThread();
709 // May only be called once per thread.
710 void set_name(const char* format, ...) ATTRIBUTE_PRINTF(2, 3);
711 virtual bool is_Named_thread() const { return true; }
|