*/
-#ifndef _THREADS_COMMON_H
-#define _THREADS_COMMON_H
+#ifndef _THREAD_H
+#define _THREAD_H
#include "config.h"
#if defined(ENABLE_THREADS)
# include "threads/posix/thread-posix.h"
#else
-# include "threads/none/threads.h"
+# include "threads/none/thread-none.h"
#endif
#include "vm/types.h"
do { \
if (opt_DebugThreads) { \
printf("[Thread %-16s: ", message); \
- threads_thread_print_info(thread); \
+ thread_print_info(thread); \
printf("]\n"); \
} \
} while (0)
}
+/* cacaothread_get_state *******************************************************
+
+ Returns the current state of the given thread.
+
+ ARGUMENTS:
+ t ... the thread to check
+
+ RETURN:
+ thread state
+
+*******************************************************************************/
+
+inline static int cacaothread_get_state(threadobject *t)
+{
+ return t->state;
+}
+
+
/* thread_is_attached **********************************************************
Returns if the given thread is attached to the VM.
+ ARGUMENTS:
+ t ... the thread to check
+
RETURN:
true .... the thread is attached to the VM
false ... the thread is not
}
+/* thread_is_interrupted *******************************************************
+
+ Check if the given thread has been interrupted.
+
+ ARGUMENTS:
+ t ... the thread to check
+
+ RETURN VALUE:
+ true, if the given thread had been interrupted
+
+*******************************************************************************/
+
+inline static bool thread_is_interrupted(threadobject *t)
+{
+ return t->interrupted;
+}
+
+
+/* thread_set_interrupted ******************************************************
+
+ Set the interrupted flag to the given value.
+
+ ARGUMENTS:
+ interrupted ... value to set
+
+*******************************************************************************/
+
+inline static void thread_set_interrupted(threadobject *t, bool interrupted)
+{
+ mutex_lock(&t->waitmutex);
+
+ /* Set interrupted flag. */
+
+ t->interrupted = interrupted;
+
+ mutex_unlock(&t->waitmutex);
+}
+
+
/* thread_is_daemon ************************************************************
Returns if the given thread is a daemon thread.
+ ARGUMENTS:
+ t ... the thread to check
+
RETURN:
true .... the thread is a daemon thread
false ... the thread is not
threadobject *t;
bool result;
- t = THREADOBJECT;
+ t = thread_get_current();
+
+ if (t == NULL)
+ return false;
+
result = thread_is_attached(t);
return result;
bool threads_attach_current_thread(JavaVMAttachArgs *vm_aargs, bool isdaemon);
void thread_fprint_name(threadobject *t, FILE *stream);
-void threads_thread_print_info(threadobject *t);
+void thread_print_info(threadobject *t);
intptr_t threads_get_current_tid(void);
-void threads_thread_state_runnable(threadobject *t);
-void threads_thread_state_waiting(threadobject *t);
-void threads_thread_state_timed_waiting(threadobject *t);
-void threads_thread_state_terminated(threadobject *t);
+void thread_set_state_runnable(threadobject *t);
+void thread_set_state_waiting(threadobject *t);
+void thread_set_state_timed_waiting(threadobject *t);
+void thread_set_state_terminated(threadobject *t);
-utf *threads_thread_get_state(threadobject *t);
threadobject *thread_get_thread(java_handle_t *h);
bool threads_thread_is_alive(threadobject *t);
void threads_dump(void);
-void threads_thread_print_stacktrace(threadobject *thread);
-void threads_print_stacktrace(void);
/* implementation specific functions */
#endif /* ENABLE_THREADS */
-#endif /* _THREADS_COMMON_H */
+#endif /* _THREAD_H */
/*