thread fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31209 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2010-08-30 17:27:11 +00:00
parent f5a7ed4073
commit df44085cad
3 changed files with 68 additions and 31 deletions

View file

@ -1009,35 +1009,43 @@ GSPrivateCheckTasks()
*/
static DWORD WINAPI _threadFunction(LPVOID t)
{
DWORD milliseconds = 60000;
int taskId = [(NSTask*)t processIdentifier];
DWORD milliseconds = 60000;
int taskId;
NSConcreteWindowsTask *task;
for (;;)
GSRegisterCurrentThread();
taskId = [(NSTask*)t processIdentifier];
[tasksLock lock];
task = (NSConcreteWindowsTask*)NSMapGet(activeTasks,
(void*)(intptr_t) taskId);
[task retain];
[tasksLock unlock];
if (task != nil)
{
NSConcreteWindowsTask *task;
[tasksLock lock];
task = (NSConcreteWindowsTask*)NSMapGet(activeTasks,
(void*)(intptr_t) taskId);
IF_NO_GC([[task retain] autorelease];)
[tasksLock unlock];
if (task == nil)
for (;;)
{
return 0; // Task gone away.
}
switch (WaitForSingleObject(task->procInfo.hProcess, milliseconds))
{
case WAIT_OBJECT_0:
handleSignal(0); // Signal child process state change.
return 0;
NSConcreteWindowsTask *present;
case WAIT_TIMEOUT:
break; // Timeout ... retry
default:
return 0; // Error ... stop watching.
[tasksLock lock];
present = (NSConcreteWindowsTask*)NSMapGet(activeTasks,
(void*)(intptr_t) taskId);
[tasksLock unlock];
if (present == nil)
{
[task release];
break; // Task gone away.
}
if (WaitForSingleObject(task->procInfo.hProcess, milliseconds)
!= WAIT_TIMEOUT)
{
[task release];
handleSignal(0); // Signal child process state change.
break;
}
}
}
GSUnregisterCurrentThread();
return 0;
}