ipc -> thread

This commit is contained in:
David Rose 2002-08-12 17:32:38 +00:00
parent 581af369ef
commit d1a921a9ab
26 changed files with 86 additions and 86 deletions

View File

@ -45,7 +45,7 @@
pta_uchar.h referenceCount.I referenceCount.h \ pta_uchar.h referenceCount.I referenceCount.h \
register_type.I register_type.h \ register_type.I register_type.h \
reversedNumericData.I reversedNumericData.h \ reversedNumericData.I reversedNumericData.h \
selectIpcImpl.h \ selectThreadImpl.h \
streamReader.I streamReader.h streamWriter.I streamWriter.h \ streamReader.I streamReader.h streamWriter.I streamWriter.h \
subStream.I subStream.h subStreamBuf.h \ subStream.I subStream.h subStreamBuf.h \
threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \
@ -130,7 +130,7 @@
profileTimer.h pta_uchar.h referenceCount.I referenceCount.h \ profileTimer.h pta_uchar.h referenceCount.I referenceCount.h \
register_type.I register_type.h \ register_type.I register_type.h \
reversedNumericData.I reversedNumericData.h \ reversedNumericData.I reversedNumericData.h \
selectIpcImpl.h \ selectThreadImpl.h \
streamReader.I streamReader.h streamWriter.I streamWriter.h \ streamReader.I streamReader.h streamWriter.I streamWriter.h \
subStream.I subStream.h subStreamBuf.h \ subStream.I subStream.h subStreamBuf.h \
threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "atomicAdjustDummyImpl.h" #include "atomicAdjustDummyImpl.h"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL

View File

@ -20,9 +20,9 @@
#define ATOMICADJUSTDUMMYIMPL_H #define ATOMICADJUSTDUMMYIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "notify.h" #include "notify.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -40,6 +40,6 @@ public:
#include "atomicAdjustDummyImpl.I" #include "atomicAdjustDummyImpl.I"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL
#endif #endif

View File

@ -20,14 +20,14 @@
#define ATOMICADJUSTIMPL_H #define ATOMICADJUSTIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#if defined(IPC_DUMMY_IMPL) #if defined(THREAD_DUMMY_IMPL)
#include "atomicAdjustDummyImpl.h" #include "atomicAdjustDummyImpl.h"
typedef AtomicAdjustDummyImpl AtomicAdjustImpl; typedef AtomicAdjustDummyImpl AtomicAdjustImpl;
#elif defined(IPC_NSPR_IMPL) #elif defined(THREAD_NSPR_IMPL)
#include "atomicAdjustNsprImpl.h" #include "atomicAdjustNsprImpl.h"
typedef AtomicAdjustNsprImpl AtomicAdjustImpl; typedef AtomicAdjustNsprImpl AtomicAdjustImpl;

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "atomicAdjustNsprImpl.h" #include "atomicAdjustNsprImpl.h"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL

View File

@ -20,9 +20,9 @@
#define ATOMICADJUSTNSPRIMPL_H #define ATOMICADJUSTNSPRIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "notify.h" #include "notify.h"
@ -41,6 +41,6 @@ public:
#include "atomicAdjustNsprImpl.I" #include "atomicAdjustNsprImpl.I"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL
#endif #endif

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "conditionVarDummyImpl.h" #include "conditionVarDummyImpl.h"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL

View File

@ -20,9 +20,9 @@
#define CONDITIONVARDUMMYIMPL_H #define CONDITIONVARDUMMYIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "notify.h" #include "notify.h"
@ -46,6 +46,6 @@ public:
#include "conditionVarDummyImpl.I" #include "conditionVarDummyImpl.I"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL
#endif #endif

View File

@ -20,14 +20,14 @@
#define CONDITIONVARIMPL_H #define CONDITIONVARIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#if defined(IPC_DUMMY_IMPL) #if defined(THREAD_DUMMY_IMPL)
#include "conditionVarDummyImpl.h" #include "conditionVarDummyImpl.h"
typedef ConditionVarDummyImpl ConditionVarImpl; typedef ConditionVarDummyImpl ConditionVarImpl;
#elif defined(IPC_NSPR_IMPL) #elif defined(THREAD_NSPR_IMPL)
#include "conditionVarNsprImpl.h" #include "conditionVarNsprImpl.h"
typedef ConditionVarNsprImpl ConditionVarImpl; typedef ConditionVarNsprImpl ConditionVarImpl;

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "conditionVarNsprImpl.h" #include "conditionVarNsprImpl.h"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL

View File

@ -20,9 +20,9 @@
#define CONDITIONVARNSPRIMPL_H #define CONDITIONVARNSPRIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "mutexNsprImpl.h" #include "mutexNsprImpl.h"
#include "notify.h" #include "notify.h"
@ -50,6 +50,6 @@ private:
#include "conditionVarNsprImpl.I" #include "conditionVarNsprImpl.I"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL
#endif #endif

View File

@ -33,7 +33,7 @@
ConfigureDef(config_express); ConfigureDef(config_express);
NotifyCategoryDef(express, ""); NotifyCategoryDef(express, "");
NotifyCategoryDef(ipc, ""); NotifyCategoryDef(thread, "");
extern void init_system_type_handles(); extern void init_system_type_handles();

View File

@ -25,7 +25,7 @@
ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS);
NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS);
NotifyCategoryDecl(ipc, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(thread, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS);
// Actually, we can't determine this config variable the normal way, // Actually, we can't determine this config variable the normal way,
// because we must be able to access it at static init time. Instead // because we must be able to access it at static init time. Instead

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "mutexDummyImpl.h" #include "mutexDummyImpl.h"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL

View File

@ -20,9 +20,9 @@
#define MUTEXDUMMYIMPL_H #define MUTEXDUMMYIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "notify.h" #include "notify.h"
@ -49,6 +49,6 @@ private:
#include "mutexDummyImpl.I" #include "mutexDummyImpl.I"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL
#endif #endif

View File

@ -24,7 +24,7 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE MutexHolder:: INLINE MutexHolder::
MutexHolder(Mutex &mutex) { MutexHolder(Mutex &mutex) {
#ifdef HAVE_IPC #ifdef HAVE_THREADS
_mutex = &mutex; _mutex = &mutex;
_mutex->lock(); _mutex->lock();
#endif #endif
@ -43,7 +43,7 @@ MutexHolder(Mutex &mutex) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE MutexHolder:: INLINE MutexHolder::
MutexHolder(Mutex *&mutex) { MutexHolder(Mutex *&mutex) {
#ifdef HAVE_IPC #ifdef HAVE_THREADS
if (mutex == (Mutex *)NULL) { if (mutex == (Mutex *)NULL) {
mutex = new Mutex; mutex = new Mutex;
} }
@ -59,7 +59,7 @@ MutexHolder(Mutex *&mutex) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
INLINE MutexHolder:: INLINE MutexHolder::
~MutexHolder() { ~MutexHolder() {
#ifdef HAVE_IPC #ifdef HAVE_THREADS
_mutex->release(); _mutex->release();
#endif #endif
} }

View File

@ -40,7 +40,7 @@ private:
INLINE void operator = (const MutexHolder &copy); INLINE void operator = (const MutexHolder &copy);
private: private:
#ifdef HAVE_IPC #ifdef HAVE_THREADS
Mutex *_mutex; Mutex *_mutex;
#endif #endif
}; };

View File

@ -20,14 +20,14 @@
#define MUTEXIMPL_H #define MUTEXIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#if defined(IPC_DUMMY_IMPL) #if defined(THREAD_DUMMY_IMPL)
#include "mutexDummyImpl.h" #include "mutexDummyImpl.h"
typedef MutexDummyImpl MutexImpl; typedef MutexDummyImpl MutexImpl;
#elif defined(IPC_NSPR_IMPL) #elif defined(THREAD_NSPR_IMPL)
#include "mutexNsprImpl.h" #include "mutexNsprImpl.h"
typedef MutexNsprImpl MutexImpl; typedef MutexNsprImpl MutexImpl;

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "mutexNsprImpl.h" #include "mutexNsprImpl.h"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL

View File

@ -20,9 +20,9 @@
#define MUTEXNSPRIMPL_H #define MUTEXNSPRIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "notify.h" #include "notify.h"
@ -47,6 +47,6 @@ private:
#include "mutexNsprImpl.I" #include "mutexNsprImpl.I"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL
#endif #endif

View File

@ -1,4 +1,4 @@
// Filename: selectIpcImpl.h // Filename: selectThreadImpl.h
// Created by: drose (09Aug02) // Created by: drose (09Aug02)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -16,32 +16,32 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifndef SELECTIPCIMPL_H #ifndef SELECTTHREADIMPL_H
#define SELECTIPCIMPL_H #define SELECTTHREADIMPL_H
#include "pandabase.h" #include "pandabase.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// This file decides which of the core implementations of the various // This file decides which of the core implementations of the various
// ipc (actually, threading) implementations we should use, based on // threading and locking implementations we should use, based on
// platform and/or available libraries. // platform and/or available libraries.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#if !defined(HAVE_IPC) #if !defined(HAVE_THREADS)
// With IPC disabled, use the do-nothing implementation. // With threading disabled, use the do-nothing implementation.
#define IPC_DUMMY_IMPL 1 #define THREAD_DUMMY_IMPL 1
#elif defined(HAVE_NSPR) #elif defined(HAVE_NSPR)
// If NSPR is available, use that. // If NSPR is available, use that.
#define IPC_NSPR_IMPL 1 #define THREAD_NSPR_IMPL 1
#else #else
// This is a configuration error. For some reason, HAVE_IPC is // This is a configuration error. For some reason, HAVE_THREADS is
// defined but we don't have any way to implement it. // defined but we don't have any way to implement it.
#error No ipc implementation defined for platform. #error No thread implementation defined for platform.
#endif #endif

View File

@ -16,10 +16,10 @@
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "threadDummyImpl.h" #include "threadDummyImpl.h"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL

View File

@ -20,9 +20,9 @@
#define THREADDUMMYIMPL_H #define THREADDUMMYIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_DUMMY_IMPL #ifdef THREAD_DUMMY_IMPL
#include "notify.h" #include "notify.h"
#include "threadPriority.h" #include "threadPriority.h"
@ -59,6 +59,6 @@ public:
#include "threadDummyImpl.I" #include "threadDummyImpl.I"
#endif // IPC_DUMMY_IMPL #endif // THREAD_DUMMY_IMPL
#endif #endif

View File

@ -20,14 +20,14 @@
#define THREADIMPL_H #define THREADIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#if defined(IPC_DUMMY_IMPL) #if defined(THREAD_DUMMY_IMPL)
#include "threadDummyImpl.h" #include "threadDummyImpl.h"
typedef ThreadDummyImpl ThreadImpl; typedef ThreadDummyImpl ThreadImpl;
#elif defined(IPC_NSPR_IMPL) #elif defined(THREAD_NSPR_IMPL)
#include "threadNsprImpl.h" #include "threadNsprImpl.h"
typedef ThreadNsprImpl ThreadImpl; typedef ThreadNsprImpl ThreadImpl;

View File

@ -17,9 +17,9 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "threadNsprImpl.h" #include "threadNsprImpl.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "pointerTo.h" #include "pointerTo.h"
#include "config_express.h" #include "config_express.h"
@ -35,8 +35,8 @@ bool ThreadNsprImpl::_got_pt_ptr_index = false;
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
ThreadNsprImpl:: ThreadNsprImpl::
~ThreadNsprImpl() { ~ThreadNsprImpl() {
if (ipc_cat.is_debug()) { if (thread_cat.is_debug()) {
ipc_cat.debug() << "Deleting thread " << _parent_obj->get_name() << "\n"; thread_cat.debug() << "Deleting thread " << _parent_obj->get_name() << "\n";
} }
// If the thread object is destructing, it means the last pointer // If the thread object is destructing, it means the last pointer
@ -70,7 +70,7 @@ ThreadNsprImpl::
// make a thread unjoinable after it has been created, and a // make a thread unjoinable after it has been created, and a
// thread can't join itself (can it?). // thread can't join itself (can it?).
if (_joinable) { if (_joinable) {
ipc_cat.warning() thread_cat.warning()
<< "thread " << _parent_obj->get_name() << " was never joined.\n"; << "thread " << _parent_obj->get_name() << " was never joined.\n";
} }
return; return;
@ -90,8 +90,8 @@ ThreadNsprImpl::
bool ThreadNsprImpl:: bool ThreadNsprImpl::
start(ThreadPriority priority, bool global, bool joinable) { start(ThreadPriority priority, bool global, bool joinable) {
MutexHolder holder(_mutex); MutexHolder holder(_mutex);
if (ipc_cat.is_debug()) { if (thread_cat.is_debug()) {
ipc_cat.debug() << "Starting thread " << _parent_obj->get_name() << "\n"; thread_cat.debug() << "Starting thread " << _parent_obj->get_name() << "\n";
} }
nassertr(_thread == (PRThread *)NULL, false); nassertr(_thread == (PRThread *)NULL, false);
_joinable = joinable; _joinable = joinable;
@ -103,7 +103,7 @@ start(ThreadPriority priority, bool global, bool joinable) {
if (result == PR_SUCCESS) { if (result == PR_SUCCESS) {
_got_pt_ptr_index = true; _got_pt_ptr_index = true;
} else { } else {
ipc_cat.error() thread_cat.error()
<< "Unable to associate Thread pointers with threads.\n"; << "Unable to associate Thread pointers with threads.\n";
return false; return false;
} }
@ -181,8 +181,8 @@ root_func(void *data) {
nassertv(result == PR_SUCCESS); nassertv(result == PR_SUCCESS);
parent_obj->thread_main(); parent_obj->thread_main();
if (ipc_cat.is_debug()) { if (thread_cat.is_debug()) {
ipc_cat.debug() thread_cat.debug()
<< "Terminating thread " << parent_obj->get_name() << "Terminating thread " << parent_obj->get_name()
<< ", count = " << parent_obj->get_ref_count() << "\n"; << ", count = " << parent_obj->get_ref_count() << "\n";
} }
@ -193,4 +193,4 @@ root_func(void *data) {
unref_delete(parent_obj); unref_delete(parent_obj);
} }
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL

View File

@ -20,9 +20,9 @@
#define THREADNSPRIMPL_H #define THREADNSPRIMPL_H
#include "pandabase.h" #include "pandabase.h"
#include "selectIpcImpl.h" #include "selectThreadImpl.h"
#ifdef IPC_NSPR_IMPL #ifdef THREAD_NSPR_IMPL
#include "notify.h" #include "notify.h"
#include "threadPriority.h" #include "threadPriority.h"
@ -65,6 +65,6 @@ private:
#include "threadNsprImpl.I" #include "threadNsprImpl.I"
#endif // IPC_NSPR_IMPL #endif // THREAD_NSPR_IMPL
#endif #endif