Rename pthread::running to pthread::valid throughout.
* thread.h: (pthread::suspend_all_except_self): New static method. (pthread::resume_all): Ditto. (pthread::suspend_except_self): New method. (pthread::resume): Ditto. * thread.cc (pthread::suspend_except_self): Implement. (pthread::resume): Ditto.
This commit is contained in:
parent
d3f6bd13cb
commit
c6e0f665bc
|
@ -1,3 +1,14 @@
|
|||
2003-10-31 Thomas Pfaff <tpfaff@gmx.net>
|
||||
|
||||
Rename pthread::running to pthread::valid throughout.
|
||||
|
||||
* thread.h: (pthread::suspend_all_except_self): New static method.
|
||||
(pthread::resume_all): Ditto.
|
||||
(pthread::suspend_except_self): New method.
|
||||
(pthread::resume): Ditto.
|
||||
* thread.cc (pthread::suspend_except_self): Implement.
|
||||
(pthread::resume): Ditto.
|
||||
|
||||
2003-10-29 Danny Smith <dannysmith@users.sourceforege.net>
|
||||
|
||||
* include/stdint.h: Prevent signed->unsigned conversion for 32 and
|
||||
|
|
|
@ -254,7 +254,7 @@ List<pthread> pthread::threads;
|
|||
|
||||
/* member methods */
|
||||
pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
|
||||
running (false), suspended (false),
|
||||
valid (false), suspended (false),
|
||||
cancelstate (0), canceltype (0), cancel_event (0),
|
||||
joiner (NULL), next (NULL), cleanup_stack (NULL)
|
||||
{
|
||||
|
@ -344,7 +344,7 @@ pthread::create (void *(*func) (void *), pthread_attr *newattr,
|
|||
void
|
||||
pthread::postcreate ()
|
||||
{
|
||||
running = true;
|
||||
valid = true;
|
||||
|
||||
InterlockedIncrement (&MT_INTERFACE->threadcount);
|
||||
/* FIXME: set the priority appropriately for system contention scope */
|
||||
|
@ -371,7 +371,7 @@ pthread::exit (void *value_ptr)
|
|||
delete this;
|
||||
else
|
||||
{
|
||||
running = false;
|
||||
valid = false;
|
||||
return_ptr = value_ptr;
|
||||
mutex.unlock ();
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ pthread::cancel (void)
|
|||
|
||||
mutex.lock ();
|
||||
|
||||
if (!running)
|
||||
if (!valid)
|
||||
{
|
||||
mutex.unlock ();
|
||||
return 0;
|
||||
|
@ -743,6 +743,7 @@ pthread::init_current_thread ()
|
|||
win32_obj_id = NULL;
|
||||
set_thread_id_to_current ();
|
||||
set_tls_self_pointer (this);
|
||||
valid = true;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -752,12 +753,26 @@ pthread::_fixup_after_fork ()
|
|||
if (this != pthread::self ())
|
||||
{
|
||||
magic = 0;
|
||||
running = false;
|
||||
valid = false;
|
||||
win32_obj_id = NULL;
|
||||
cancel_event = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
pthread::suspend_except_self ()
|
||||
{
|
||||
if (valid && this != pthread::self ())
|
||||
SuspendThread (win32_obj_id);
|
||||
}
|
||||
|
||||
void
|
||||
pthread::resume ()
|
||||
{
|
||||
if (valid)
|
||||
ResumeThread (win32_obj_id);
|
||||
}
|
||||
|
||||
/* static members */
|
||||
bool
|
||||
pthread_attr::is_good_object (pthread_attr_t const *attr)
|
||||
|
@ -2332,7 +2347,7 @@ pthread::detach (pthread_t *thread)
|
|||
}
|
||||
|
||||
// check if thread is still alive
|
||||
if ((*thread)->running && WaitForSingleObject ((*thread)->win32_obj_id, 0) == WAIT_TIMEOUT)
|
||||
if ((*thread)->valid && WaitForSingleObject ((*thread)->win32_obj_id, 0) == WAIT_TIMEOUT)
|
||||
{
|
||||
// force cleanup on exit
|
||||
(*thread)->joiner = *thread;
|
||||
|
|
|
@ -456,7 +456,7 @@ public:
|
|||
void *(*function) (void *);
|
||||
void *arg;
|
||||
void *return_ptr;
|
||||
bool running;
|
||||
bool valid;
|
||||
bool suspended;
|
||||
int cancelstate, canceltype;
|
||||
HANDLE cancel_event;
|
||||
|
@ -521,12 +521,25 @@ public:
|
|||
threads.for_each (&pthread::_fixup_after_fork);
|
||||
}
|
||||
|
||||
static void suspend_all_except_self ()
|
||||
{
|
||||
threads.for_each (&pthread::suspend_except_self);
|
||||
}
|
||||
|
||||
static void resume_all ()
|
||||
{
|
||||
threads.for_each (&pthread::resume);
|
||||
}
|
||||
|
||||
private:
|
||||
static List<pthread> threads;
|
||||
DWORD thread_id;
|
||||
__pthread_cleanup_handler *cleanup_stack;
|
||||
pthread_mutex mutex;
|
||||
|
||||
void suspend_except_self ();
|
||||
void resume ();
|
||||
|
||||
void _fixup_after_fork ();
|
||||
|
||||
void pop_all_cleanup_handlers (void);
|
||||
|
|
Loading…
Reference in New Issue