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