summaryrefslogtreecommitdiff
path: root/libjava/posix-threads.cc
diff options
context:
space:
mode:
authorbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-22 06:47:48 +0000
committerbothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-22 06:47:48 +0000
commit98cf095aceed6a89d0524b8cfbcb11a5ee823c70 (patch)
treeecfc0fb5d915f5f6596ef061114d1b6b7ec5270a /libjava/posix-threads.cc
parent4737d8efd8bdfccb3d0d41413aaf3933f25780ce (diff)
downloadgcc-98cf095aceed6a89d0524b8cfbcb11a5ee823c70.tar.gz
Implement invocation interface; don't create new thread for main.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42428 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/posix-threads.cc')
-rw-r--r--libjava/posix-threads.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/libjava/posix-threads.cc b/libjava/posix-threads.cc
index c38cee6f8ae..286bf83116f 100644
--- a/libjava/posix-threads.cc
+++ b/libjava/posix-threads.cc
@@ -326,6 +326,25 @@ _Jv_ThreadSetPriority (_Jv_Thread_t *data, jint prio)
}
}
+void
+_Jv_ThreadRegister (_Jv_Thread_t *data)
+{
+ pthread_setspecific (_Jv_ThreadKey, data->thread_obj);
+ pthread_setspecific (_Jv_ThreadDataKey, data);
+
+ // glibc 2.1.3 doesn't set the value of `thread' until after start_routine
+ // is called. Since it may need to be accessed from the new thread, work
+ // around the potential race here by explicitly setting it again.
+ data->thread = pthread_self ();
+}
+
+void
+_Jv_ThreadUnRegister ()
+{
+ pthread_setspecific (_Jv_ThreadKey, NULL);
+ pthread_setspecific (_Jv_ThreadDataKey, NULL);
+}
+
// This function is called when a thread is started. We don't arrange
// to call the `run' method directly, because this function must
// return a value.
@@ -334,13 +353,7 @@ really_start (void *x)
{
struct starter *info = (struct starter *) x;
- pthread_setspecific (_Jv_ThreadKey, info->data->thread_obj);
- pthread_setspecific (_Jv_ThreadDataKey, info->data);
-
- // glibc 2.1.3 doesn't set the value of `thread' until after start_routine
- // is called. Since it may need to be accessed from the new thread, work
- // around the potential race here by explicitly setting it again.
- info->data->thread = pthread_self ();
+ _Jv_ThreadRegister (info->data);
info->method (info->data->thread_obj);