win32-threads.cc: (ensure_interrupt_event_initialized) New function for lazy initialization of an...

* win32-threads.cc: (ensure_interrupt_event_initialized) New
	function for lazy initialization of an auto-reset event.
	(_Jv_CondWait) Added thread interrupt support.
	(_Jv_ThreadInitData) Added initialization of interrupt support
	members.
	(_Jv_ThreadDestroyData) Added cleanup of interrupt support members.
	(_Jv_ThreadStart) Removed unused code.
	(_Jv_Win32GetInterruptEvent) New method for returning interrupt event
	to an external caller.
	(_Jv_ThreadInterrupt) Implemented.
	* include/win32-threads.h: (_Jv_Thread_t) Added a Win32 auto-reset
	event for interrupt support as well as a mutex which regulates
	access to this.
	(_Jv_Win32GetInterruptEvent) Declared new method for returning interrupt
	event to an external caller.
	* java/lang/natWin32Process.cc: (cleanup) Close handle to spawned
	process.
	(waitFor) Added interrupt support.

From-SVN: r71562
This commit is contained in:
Mohan Embar 2003-09-19 08:28:43 +00:00 committed by Mohan Embar
parent 65f070242b
commit b90e0e3cdb
4 changed files with 152 additions and 11 deletions

View file

@ -50,6 +50,14 @@ typedef struct
{
int flags; // Flags are defined in implementation.
HANDLE handle; // Actual handle to the thread
// Protects access to the thread's interrupt_flag and
// interrupt_event variables within this module.
CRITICAL_SECTION interrupt_mutex;
// A Win32 auto-reset event for thread interruption
HANDLE interrupt_event;
java::lang::Thread *thread_obj;
} _Jv_Thread_t;
@ -150,6 +158,24 @@ void _Jv_ThreadStart (java::lang::Thread *thread, _Jv_Thread_t *data,
void _Jv_ThreadWait (void);
void _Jv_ThreadInterrupt (_Jv_Thread_t *data);
//
// Thread interruption support
//
// Gets the auto-reset event for the current thread which is
// signalled by _Jv_ThreadInterrupt. The caller can wait on this
// event in addition to other waitable objects.
//
// NOTE: After waiting on this event with WaitForMultipleObjects,
// you should ALWAYS use the return value of WaitForMultipleObjects
// to test whether this event was signalled and whether thread
// interruption has occurred. You should do this instead of checking
// the thread's interrupted_flag, because someone could have reset
// this flag in the interval of time between the return of
// WaitForMultipleObjects and the time you query interrupted_flag.
// See java/lang/natWin32Process.cc (waitFor) for an example.
HANDLE _Jv_Win32GetInterruptEvent (void);
// Remove defines from <windows.h> that conflict with various things in libgcj code
#undef TRUE