spacing cleanup
This commit is contained in:
parent
ee8d419fd4
commit
9a47ce7f74
|
@ -254,7 +254,7 @@ pthread::initMainThread (bool do_init)
|
|||
{
|
||||
thread = new pthread ();
|
||||
if (!thread)
|
||||
api_fatal ("failed to create mainthread object");
|
||||
api_fatal ("failed to create mainthread object");
|
||||
}
|
||||
|
||||
thread->initCurrentThread ();
|
||||
|
@ -632,7 +632,8 @@ pthread::static_cancel_self (void)
|
|||
}
|
||||
|
||||
|
||||
DWORD pthread::cancelable_wait (HANDLE object, DWORD timeout, const bool do_cancel)
|
||||
DWORD
|
||||
pthread::cancelable_wait (HANDLE object, DWORD timeout, const bool do_cancel)
|
||||
{
|
||||
DWORD res;
|
||||
HANDLE wait_objects[2];
|
||||
|
@ -751,8 +752,8 @@ pthread::initCurrentThread ()
|
|||
{
|
||||
cancel_event = ::CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
||||
if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
|
||||
GetCurrentProcess (), &win32_obj_id,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS))
|
||||
GetCurrentProcess (), &win32_obj_id,
|
||||
0, FALSE, DUPLICATE_SAME_ACCESS))
|
||||
win32_obj_id = NULL;
|
||||
setThreadIdtoCurrent ();
|
||||
setTlsSelfPointer (this);
|
||||
|
@ -947,7 +948,7 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
|
|||
*/
|
||||
|
||||
rv = SignalObjectAndWait (mutex->win32_obj_id, win32_obj_id, dwMilliseconds,
|
||||
false);
|
||||
false);
|
||||
#endif
|
||||
switch (rv)
|
||||
{
|
||||
|
@ -1093,8 +1094,8 @@ pthread_key::run_destructor ()
|
|||
void *oldValue = get ();
|
||||
if (oldValue)
|
||||
{
|
||||
set (NULL);
|
||||
destructor (oldValue);
|
||||
set (NULL);
|
||||
destructor (oldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1174,7 +1175,7 @@ pthread_mutex::pthread_mutex (pthread_mutexattr *attr) :
|
|||
lock_counter (MUTEX_LOCK_COUNTER_INITIAL),
|
||||
win32_obj_id (NULL), recursion_counter (0),
|
||||
condwaits (0), owner (NULL), type (PTHREAD_MUTEX_DEFAULT),
|
||||
pshared(PTHREAD_PROCESS_PRIVATE)
|
||||
pshared (PTHREAD_PROCESS_PRIVATE)
|
||||
{
|
||||
win32_obj_id = ::CreateSemaphore (&sec_none_nih, 0, LONG_MAX, NULL);
|
||||
if (!win32_obj_id)
|
||||
|
@ -1186,11 +1187,11 @@ pthread_mutex::pthread_mutex (pthread_mutexattr *attr) :
|
|||
if (attr)
|
||||
{
|
||||
if (attr->pshared == PTHREAD_PROCESS_SHARED)
|
||||
{
|
||||
// fail
|
||||
magic = 0;
|
||||
return;
|
||||
}
|
||||
{
|
||||
// fail
|
||||
magic = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
type = attr->mutextype;
|
||||
}
|
||||
|
@ -1212,7 +1213,7 @@ pthread_mutex::~pthread_mutex ()
|
|||
{
|
||||
pthread_mutex *tempmutex = MT_INTERFACE->mutexs;
|
||||
while (tempmutex->next && tempmutex->next != this)
|
||||
tempmutex = tempmutex->next;
|
||||
tempmutex = tempmutex->next;
|
||||
/* but there may be a race between the loop above and this statement */
|
||||
/* TODO: printf an error if the return value != this */
|
||||
InterlockedExchangePointer (&tempmutex->next, this->next);
|
||||
|
@ -1231,9 +1232,9 @@ pthread_mutex::Lock ()
|
|||
{
|
||||
InterlockedDecrement (&lock_counter);
|
||||
if (PTHREAD_MUTEX_RECURSIVE == type)
|
||||
result = LockRecursive ();
|
||||
result = LockRecursive ();
|
||||
else
|
||||
result = EDEADLK;
|
||||
result = EDEADLK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1274,8 +1275,8 @@ pthread_mutex::UnLock ()
|
|||
{
|
||||
owner = NULL;
|
||||
if (MUTEX_LOCK_COUNTER_INITIAL != InterlockedDecrement (&lock_counter))
|
||||
// Another thread is waiting
|
||||
::ReleaseSemaphore (win32_obj_id, 1, NULL);
|
||||
// Another thread is waiting
|
||||
::ReleaseSemaphore (win32_obj_id, 1, NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1908,23 +1909,23 @@ pthread::join (pthread_t *thread, void **return_val)
|
|||
(*thread)->mutex.UnLock ();
|
||||
|
||||
switch (cancelable_wait ((*thread)->win32_obj_id, INFINITE, false))
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
if (return_val)
|
||||
*return_val = (*thread)->return_ptr;
|
||||
delete (*thread);
|
||||
break;
|
||||
case WAIT_CANCELED:
|
||||
// set joined thread back to joinable since we got canceled
|
||||
(*thread)->joiner = NULL;
|
||||
(*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE;
|
||||
joiner->cancel_self ();
|
||||
// never reached
|
||||
break;
|
||||
default:
|
||||
// should never happen
|
||||
return EINVAL;
|
||||
}
|
||||
{
|
||||
case WAIT_OBJECT_0:
|
||||
if (return_val)
|
||||
*return_val = (*thread)->return_ptr;
|
||||
delete (*thread);
|
||||
break;
|
||||
case WAIT_CANCELED:
|
||||
// set joined thread back to joinable since we got canceled
|
||||
(*thread)->joiner = NULL;
|
||||
(*thread)->attr.joinable = PTHREAD_CREATE_JOINABLE;
|
||||
joiner->cancel_self ();
|
||||
// never reached
|
||||
break;
|
||||
default:
|
||||
// should never happen
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -2768,6 +2769,7 @@ void
|
|||
pthreadNull::pop_cleanup_handler (int const execute)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned long
|
||||
pthreadNull::getsequence_np ()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue