invocation interface

Per Bothner per@bothner.com
Mon May 14 08:35:00 GMT 2001


I'm taking a look at a working Java invocation interface, including
getting rid of the FirstThread. I notice there is a
_Jv_JNI_AttachCurrentThread function and a gnu.gcj.jni.NativeThread
class. Do these actually do anything? I don't see where the
NativeThread is connected to the current thread.
I thought about adding a CNI method vaguely like:
java::lang::Thread*
_Jv_AttachCurrentThread(jstring name, java::lang::ThreadGroup* group)
{
 if (already attached)
 return current Thread;
 if (name == NULL)
 name = generate name;
 if (group == NULL)
 group = ThreadGroup.root;
 Thread *thread = new Thread(..); // Do-nothing constructor.
 group->addThread(thread);
 thread->runnable = NULL; // or magic value?
 thread->data = NULL;
 thread->interrupt_flag = false;
 thread->alive_flag = false;
 thread->startable_flag = false;
 thread->daemon_flag = false;
 thread->priority = NORM_PRIORITY;
 thread->alive_flag = true;
 thread->initialize_native ();
 _Jv_Thread_t *data = nt->thread;
#if 1
 struct starter info;
 info.data = data;
 pthread::really_start (&info); // FIXME
#else
 natThread *nt = (natThread *) thread->data;
 date->thread = pthread_self (); // FIXME
#endif
}
We'd need a new private Thread constructor, one that
does not call currentThread ().
The _Jv_JNI_AttachCurrentThread method would loosely be
a wrapper around _Jv_AttachCurrentThread.
The FirstThread and NativeThread classes would both go away.
Comments?
-- 
	--Per Bothner
per@bothner.com http://www.bothner.com/per/


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /