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:
parent
65f070242b
commit
b90e0e3cdb
4 changed files with 152 additions and 11 deletions
|
@ -46,6 +46,11 @@ java::lang::ConcreteProcess::cleanup (void)
|
|||
errorStream->close ();
|
||||
errorStream = NULL;
|
||||
}
|
||||
if (procHandle)
|
||||
{
|
||||
CloseHandle((HANDLE) procHandle);
|
||||
procHandle = (jint) INVALID_HANDLE_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -92,8 +97,28 @@ java::lang::ConcreteProcess::waitFor (void)
|
|||
{
|
||||
DWORD exitStatus = 0UL;
|
||||
|
||||
// FIXME: The wait should be interruptible.
|
||||
WaitForSingleObject ((HANDLE) procHandle, INFINITE);
|
||||
// Set up our waitable objects array
|
||||
// - 0: the handle to the process we just launched
|
||||
// - 1: our thread's interrupt event
|
||||
HANDLE arh[2];
|
||||
arh[0] = (HANDLE) procHandle;
|
||||
arh[1] = _Jv_Win32GetInterruptEvent ();
|
||||
DWORD rval = WaitForMultipleObjects (2, arh, 0, INFINITE);
|
||||
|
||||
// Use the returned value from WaitForMultipleObjects
|
||||
// instead of our thread's interrupt_flag to test for
|
||||
// thread interruption. See the comment for
|
||||
// _Jv_Win32GetInterruptEvent().
|
||||
bool bInterrupted = rval == (WAIT_OBJECT_0 + 1);
|
||||
|
||||
if (bInterrupted)
|
||||
{
|
||||
// Querying this forces a reset our thread's interrupt flag.
|
||||
Thread::interrupted();
|
||||
|
||||
cleanup ();
|
||||
throw new InterruptedException ();
|
||||
}
|
||||
|
||||
GetExitCodeProcess ((HANDLE) procHandle, &exitStatus);
|
||||
exitCode = exitStatus;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue