diff --git a/panda/metalibs/panda/Sources.pp b/panda/metalibs/panda/Sources.pp index 5e4597da21..6bc89a7d49 100644 --- a/panda/metalibs/panda/Sources.pp +++ b/panda/metalibs/panda/Sources.pp @@ -9,7 +9,7 @@ #define USE_PACKAGES net #define COMPONENT_LIBS \ - recorder pgraph \ + recorder pgraph pipeline \ pvrpn grutil chan pstatclient \ char chat collide cull device \ dgraph display event gobj graph gsgbase \ diff --git a/panda/metalibs/pandaexpress/Sources.pp b/panda/metalibs/pandaexpress/Sources.pp index 7081b66d1f..13c6205d15 100644 --- a/panda/metalibs/pandaexpress/Sources.pp +++ b/panda/metalibs/pandaexpress/Sources.pp @@ -8,7 +8,7 @@ #define BUILDING_DLL BUILDING_PANDAEXPRESS #define USE_PACKAGES net -#define COMPONENT_LIBS downloader ipc express pandabase +#define COMPONENT_LIBS downloader express pandabase #define OTHER_LIBS dconfig:c prc:c interrogatedb:c dtoolutil:c dtoolbase:c dtoolconfig:m dtool:m #begin metalib_target diff --git a/panda/src/express/Sources.pp b/panda/src/express/Sources.pp index fcbdbf8ddf..9a9ab4096f 100644 --- a/panda/src/express/Sources.pp +++ b/panda/src/express/Sources.pp @@ -9,63 +9,31 @@ #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx #define SOURCES \ - atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ - atomicAdjust.I atomicAdjustImpl.h \ - atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ - atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ - atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ bigEndian.h buffer.I buffer.h \ checksumHashGenerator.I checksumHashGenerator.h circBuffer.I \ - circBuffer.h clockObject.I clockObject.h \ - conditionVar.h conditionVar.I \ - conditionVarDebug.h conditionVarDebug.I \ - conditionVarDirect.h conditionVarDirect.I \ - conditionVarDummyImpl.h conditionVarDummyImpl.I \ - conditionVarImpl.h \ - conditionVarNsprImpl.h conditionVarNsprImpl.I \ - conditionVarPosixImpl.h conditionVarPosixImpl.I \ - conditionVarWin32Impl.h conditionVarWin32Impl.I \ + circBuffer.h \ config_express.h \ - cycleData.h cycleData.I \ - cycleDataReader.h cycleDataReader.I \ - cycleDataStageReader.h cycleDataStageReader.I \ - cycleDataStageWriter.h cycleDataStageWriter.I \ - cycleDataWriter.h cycleDataWriter.I \ - cyclerHolder.h cyclerHolder.I \ datagram.I datagram.h datagramGenerator.I \ datagramGenerator.h \ datagramIterator.I datagramIterator.h datagramSink.I datagramSink.h \ dcast.T dcast.h \ encryptStreamBuf.h encryptStreamBuf.I encryptStream.h encryptStream.I \ error_utils.h \ - externalThread.h \ hashGeneratorBase.I hashGeneratorBase.h \ hashVal.I hashVal.h \ indirectLess.I indirectLess.h \ littleEndian.h \ - mainThread.h \ memoryInfo.I memoryInfo.h \ memoryUsage.I memoryUsage.h \ memoryUsagePointerCounts.I memoryUsagePointerCounts.h \ memoryUsagePointers.I memoryUsagePointers.h \ multifile.I multifile.h \ - mutexDebug.h mutexDebug.I \ - mutexDirect.h mutexDirect.I \ - mutexHolder.h mutexHolder.I \ namable.I \ namable.h nativeNumericData.I nativeNumericData.h \ numeric_types.h \ ordered_vector.h ordered_vector.I ordered_vector.T \ password_hash.h \ patchfile.I patchfile.h \ - pipeline.h pipeline.I \ - pipelineCycler.h pipelineCycler.I \ - pipelineCyclerLinks.h pipelineCyclerLinks.I \ - pipelineCyclerBase.h \ - pipelineCyclerDummyImpl.h pipelineCyclerDummyImpl.I \ - pipelineCyclerTrivialImpl.h pipelineCyclerTrivialImpl.I \ - pipelineCyclerTrueImpl.h pipelineCyclerTrueImpl.I \ - pmutex.h pmutex.I \ pointerTo.I pointerTo.h \ pointerToArray.I pointerToArray.h \ pointerToBase.I pointerToBase.h \ @@ -74,19 +42,11 @@ pta_uchar.h \ ramfile.I ramfile.h \ referenceCount.I referenceCount.h \ - reMutex.I reMutex.h \ - reMutexDirect.h reMutexDirect.I \ - reMutexHolder.I reMutexHolder.h \ reversedNumericData.I reversedNumericData.h \ streamReader.I streamReader.h streamWriter.I streamWriter.h \ stringDecoder.h stringDecoder.I \ subStream.I subStream.h subStreamBuf.h \ textEncoder.h textEncoder.I \ - threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ - threadNsprImpl.h threadNsprImpl.I \ - threadPosixImpl.h threadPosixImpl.I \ - threadWin32Impl.h threadWin32Impl.I \ - threadPriority.h \ tokenBoard.I \ tokenBoard.h trueClock.I trueClock.h \ typedReferenceCount.I typedReferenceCount.h typedef.h \ @@ -106,44 +66,16 @@ zStream.I zStream.h zStreamBuf.h #define INCLUDED_SOURCES \ - atomicAdjust.cxx atomicAdjustDummyImpl.cxx \ - atomicAdjustNsprImpl.cxx \ - atomicAdjustPosixImpl.cxx \ - atomicAdjustWin32Impl.cxx \ - buffer.cxx checksumHashGenerator.cxx clockObject.cxx \ - conditionVar.cxx \ - conditionVarDebug.cxx \ - conditionVarDirect.cxx \ - conditionVarDummyImpl.cxx \ - conditionVarNsprImpl.cxx \ - conditionVarPosixImpl.cxx \ - conditionVarWin32Impl.cxx \ + buffer.cxx checksumHashGenerator.cxx \ config_express.cxx \ - cycleData.cxx \ - cycleDataReader.cxx \ - cycleDataStageReader.cxx \ - cycleDataStageWriter.cxx \ - cycleDataWriter.cxx \ - cyclerHolder.cxx \ datagram.cxx datagramGenerator.cxx \ datagramIterator.cxx \ datagramSink.cxx dcast.cxx \ encryptStreamBuf.cxx encryptStream.cxx \ error_utils.cxx \ - externalThread.cxx \ hashGeneratorBase.cxx hashVal.cxx \ - mainThread.cxx \ memoryInfo.cxx memoryUsage.cxx memoryUsagePointerCounts.cxx \ memoryUsagePointers.cxx multifile.cxx \ - mutexDebug.cxx \ - mutexDirect.cxx \ - mutexHolder.cxx \ - pipeline.cxx \ - pipelineCycler.cxx \ - pipelineCyclerDummyImpl.cxx \ - pipelineCyclerTrivialImpl.cxx \ - pipelineCyclerTrueImpl.cxx \ - pmutex.cxx \ namable.cxx \ nativeNumericData.cxx \ ordered_vector.cxx \ @@ -157,18 +89,11 @@ pta_uchar.cxx \ ramfile.cxx \ referenceCount.cxx \ - reMutex.cxx \ - reMutexDirect.cxx \ - reMutexHolder.cxx \ reversedNumericData.cxx \ streamReader.cxx streamWriter.cxx \ stringDecoder.cxx \ subStream.cxx subStreamBuf.cxx \ textEncoder.cxx \ - thread.cxx threadDummyImpl.cxx \ - threadNsprImpl.cxx \ - threadPosixImpl.cxx \ - threadWin32Impl.cxx \ trueClock.cxx \ typedReferenceCount.cxx \ unicodeLatinMap.cxx \ @@ -185,86 +110,47 @@ zStream.cxx zStreamBuf.cxx #define INSTALL_HEADERS \ - atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ - atomicAdjust.I atomicAdjustImpl.h \ - atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ - atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ - atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ - bigEndian.h buffer.I buffer.h checksumHashGenerator.I \ - checksumHashGenerator.h circBuffer.I circBuffer.h clockObject.I \ - clockObject.h \ - conditionVar.h conditionVar.I \ - conditionVarDebug.h conditionVarDebug.I \ - conditionVarDirect.h conditionVarDirect.I \ - conditionVarDummyImpl.h conditionVarDummyImpl.I \ - conditionVarImpl.h \ - conditionVarNsprImpl.h conditionVarNsprImpl.I \ - conditionVarPosixImpl.h conditionVarPosixImpl.I \ - conditionVarWin32Impl.h conditionVarWin32Impl.I \ + bigEndian.h buffer.I buffer.h \ + checksumHashGenerator.I checksumHashGenerator.h circBuffer.I \ + circBuffer.h \ config_express.h \ - cycleData.h cycleData.I \ - cycleDataReader.h cycleDataReader.I \ - cycleDataStageReader.h cycleDataStageReader.I \ - cycleDataStageWriter.h cycleDataStageWriter.I \ - cycleDataWriter.h cycleDataWriter.I \ - cyclerHolder.h cyclerHolder.I \ - datagram.I datagram.h \ - datagramGenerator.I datagramGenerator.h \ - datagramIterator.I datagramIterator.h \ - datagramSink.I datagramSink.h dcast.T dcast.h \ + datagram.I datagram.h datagramGenerator.I \ + datagramGenerator.h \ + datagramIterator.I datagramIterator.h datagramSink.I datagramSink.h \ + dcast.T dcast.h \ encryptStreamBuf.h encryptStreamBuf.I encryptStream.h encryptStream.I \ - error_utils.h \ - externalThread.h \ - hashGeneratorBase.I \ - hashGeneratorBase.h hashVal.I hashVal.h \ + error_utils.h \ + hashGeneratorBase.I hashGeneratorBase.h \ + hashVal.I hashVal.h \ indirectLess.I indirectLess.h \ littleEndian.h \ - mainThread.h \ - memoryInfo.I memoryInfo.h memoryUsage.I \ - memoryUsage.h memoryUsagePointerCounts.I \ - memoryUsagePointerCounts.h memoryUsagePointers.I \ - memoryUsagePointers.h multifile.I multifile.h \ - mutexDebug.h mutexDebug.I \ - mutexDirect.h mutexDirect.I \ - mutexHolder.h mutexHolder.I \ - namable.I namable.h \ - nativeNumericData.I nativeNumericData.h numeric_types.h \ + memoryInfo.I memoryInfo.h \ + memoryUsage.I memoryUsage.h \ + memoryUsagePointerCounts.I memoryUsagePointerCounts.h \ + memoryUsagePointers.I memoryUsagePointers.h \ + multifile.I multifile.h \ + namable.I \ + namable.h nativeNumericData.I nativeNumericData.h \ + numeric_types.h \ ordered_vector.h ordered_vector.I ordered_vector.T \ password_hash.h \ patchfile.I patchfile.h \ - pipeline.h pipeline.I \ - pipelineCycler.h pipelineCycler.I \ - pipelineCyclerLinks.h pipelineCyclerLinks.I \ - pipelineCyclerBase.h \ - pipelineCyclerDummyImpl.h pipelineCyclerDummyImpl.I \ - pipelineCyclerTrivialImpl.h pipelineCyclerTrivialImpl.I \ - pipelineCyclerTrueImpl.h pipelineCyclerTrueImpl.I \ - pmutex.h pmutex.I \ pointerTo.I pointerTo.h \ pointerToArray.I pointerToArray.h \ pointerToBase.I pointerToBase.h \ pointerToVoid.I pointerToVoid.h \ - profileTimer.I \ - profileTimer.h pta_uchar.h \ + profileTimer.I profileTimer.h \ + pta_uchar.h \ ramfile.I ramfile.h \ referenceCount.I referenceCount.h \ - reMutex.I reMutex.h \ - reMutexDirect.h reMutexDirect.I \ - reMutexHolder.I reMutexHolder.h \ reversedNumericData.I reversedNumericData.h \ streamReader.I streamReader.h streamWriter.I streamWriter.h \ stringDecoder.h stringDecoder.I \ subStream.I subStream.h subStreamBuf.h \ textEncoder.h textEncoder.I \ - threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ - threadNsprImpl.h threadNsprImpl.I \ - threadPosixImpl.h threadPosixImpl.I \ - threadWin32Impl.h threadWin32Impl.I \ - threadPriority.h \ tokenBoard.I \ tokenBoard.h trueClock.I trueClock.h \ - typedReferenceCount.I \ - typedReferenceCount.h typedef.h \ + typedReferenceCount.I typedReferenceCount.h typedef.h \ unicodeLatinMap.h \ vector_uchar.h \ virtualFileComposite.h virtualFileComposite.I virtualFile.h \ @@ -321,26 +207,3 @@ #end test_bin_target #endif - - -#begin test_bin_target - #define TARGET test_threaddata - #define LOCAL_LIBS $[LOCAL_LIBS] express - #define OTHER_LIBS dtoolutil:c dtool:m pystub - - #define SOURCES \ - test_threaddata.cxx - -#end test_bin_target - - -#begin test_bin_target - #define TARGET test_diners - #define LOCAL_LIBS $[LOCAL_LIBS] express - #define OTHER_LIBS dtoolutil:c dtool:m dtoolconfig:m pystub - - #define SOURCES \ - test_diners.cxx - -#end test_bin_target - diff --git a/panda/src/express/config_express.cxx b/panda/src/express/config_express.cxx index 419b76ad7d..8e61e2e2e8 100644 --- a/panda/src/express/config_express.cxx +++ b/panda/src/express/config_express.cxx @@ -1,5 +1,5 @@ // Filename: config_express.cxx -// Created by: cary (04Jan00) +// Created by: drose (28Mar06) // //////////////////////////////////////////////////////////////////// // @@ -16,15 +16,10 @@ // //////////////////////////////////////////////////////////////////// - #include "config_express.h" -#include "clockObject.h" #include "datagram.h" -#include "mainThread.h" -#include "externalThread.h" #include "referenceCount.h" #include "textEncoder.h" -#include "thread.h" #include "typedObject.h" #include "typedReferenceCount.h" #include "virtualFile.h" @@ -39,7 +34,6 @@ ConfigureDef(config_express); NotifyCategoryDef(express, ""); -NotifyCategoryDef(thread, ""); ConfigureFn(config_express) { init_libexpress(); @@ -67,20 +61,6 @@ ConfigVariableBool keep_temporary_files ConfigVariableDouble average_frame_rate_interval ("average-frame-rate-interval", 1.0); -ConfigVariableDouble clock_frame_rate -("clock-frame-rate", 1.0); -ConfigVariableDouble clock_degrade_factor -("clock-degrade-factor", 1.0); -ConfigVariableDouble max_dt -("max-dt", -1.0); - -ConfigVariableDouble sleep_precision -("sleep-precision", 0.01, - PRC_DESC("This is the accuracy within which we can expect select() to " - "return precisely. That is, if we use select() to request a " - "timeout of 1.0 seconds, we can expect to actually sleep for " - "somewhere between 1.0 and 1.0 + sleep-precision seconds.")); - ConfigVariableString encryption_algorithm ("encryption-algorithm", "bf-cbc", PRC_DESC("This defines the OpenSSL encryption algorithm which is used to " @@ -169,13 +149,9 @@ init_libexpress() { } initialized = true; - ClockObject::init_type(); Datagram::init_type(); - MainThread::init_type(); - ExternalThread::init_type(); ReferenceCount::init_type(); TextEncoder::init_type(); - Thread::init_type(); TypedObject::init_type(); TypedReferenceCount::init_type(); VirtualFile::init_type(); @@ -193,13 +169,6 @@ init_libexpress() { ps->add_system("zlib"); } #endif - -#ifdef HAVE_THREADS - { - PandaSystem *ps = PandaSystem::get_global_ptr(); - ps->add_system("threads"); - } -#endif } diff --git a/panda/src/express/config_express.h b/panda/src/express/config_express.h index 1752ba2591..b7f8eb7e2e 100644 --- a/panda/src/express/config_express.h +++ b/panda/src/express/config_express.h @@ -43,7 +43,6 @@ ConfigureDecl(config_express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); NotifyCategoryDecl(express, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); -NotifyCategoryDecl(thread, EXPCL_PANDAEXPRESS, EXPTP_PANDAEXPRESS); // Actually, we can't determine this config variable the normal way, // because we must be able to access it at static init time. Instead @@ -67,11 +66,6 @@ extern ConfigVariableInt patchfile_zone_size; extern ConfigVariableBool keep_temporary_files; extern ConfigVariableDouble average_frame_rate_interval; -extern ConfigVariableDouble clock_frame_rate; -extern ConfigVariableDouble clock_degrade_factor; -extern ConfigVariableDouble max_dt; -extern ConfigVariableDouble sleep_precision; - extern ConfigVariableString encryption_algorithm; extern ConfigVariableInt encryption_key_length; extern ConfigVariableInt encryption_iteration_count; diff --git a/panda/src/express/express_composite1.cxx b/panda/src/express/express_composite1.cxx index 07e8d034b0..300050f3a4 100644 --- a/panda/src/express/express_composite1.cxx +++ b/panda/src/express/express_composite1.cxx @@ -1,25 +1,6 @@ -#include "atomicAdjust.cxx" -#include "atomicAdjustDummyImpl.cxx" -#include "atomicAdjustNsprImpl.cxx" -#include "atomicAdjustPosixImpl.cxx" -#include "atomicAdjustWin32Impl.cxx" #include "buffer.cxx" #include "checksumHashGenerator.cxx" -#include "clockObject.cxx" -#include "conditionVar.cxx" -#include "conditionVarDebug.cxx" -#include "conditionVarDirect.cxx" -#include "conditionVarDummyImpl.cxx" -#include "conditionVarNsprImpl.cxx" -#include "conditionVarPosixImpl.cxx" -#include "conditionVarWin32Impl.cxx" #include "config_express.cxx" -#include "cycleData.cxx" -#include "cycleDataReader.cxx" -#include "cycleDataStageReader.cxx" -#include "cycleDataStageWriter.cxx" -#include "cycleDataWriter.cxx" -#include "cyclerHolder.cxx" #include "datagram.cxx" #include "datagramGenerator.cxx" #include "datagramIterator.cxx" @@ -28,20 +9,20 @@ #include "error_utils.cxx" #include "encryptStreamBuf.cxx" #include "encryptStream.cxx" -#include "externalThread.cxx" #include "hashGeneratorBase.cxx" #include "hashVal.cxx" -#include "mainThread.cxx" #include "memoryInfo.cxx" #include "memoryUsage.cxx" #include "memoryUsagePointerCounts.cxx" #include "memoryUsagePointers.cxx" #include "multifile.cxx" -#include "mutexDebug.cxx" -#include "mutexDirect.cxx" -#include "mutexHolder.cxx" #include "namable.cxx" #include "nativeNumericData.cxx" #include "ordered_vector.cxx" #include "patchfile.cxx" #include "password_hash.cxx" +#include "pointerTo.cxx" +#include "pointerToArray.cxx" +#include "pointerToBase.cxx" +#include "pointerToVoid.cxx" +#include "profileTimer.cxx" diff --git a/panda/src/express/express_composite2.cxx b/panda/src/express/express_composite2.cxx index fdc96afcb1..09a4105f31 100644 --- a/panda/src/express/express_composite2.cxx +++ b/panda/src/express/express_composite2.cxx @@ -1,19 +1,6 @@ -#include "pipeline.cxx" -#include "pipelineCycler.cxx" -#include "pipelineCyclerDummyImpl.cxx" -#include "pipelineCyclerTrivialImpl.cxx" -#include "pipelineCyclerTrueImpl.cxx" -#include "pmutex.cxx" -#include "pointerTo.cxx" -#include "pointerToArray.cxx" -#include "pointerToBase.cxx" -#include "pointerToVoid.cxx" -#include "profileTimer.cxx" #include "pta_uchar.cxx" #include "ramfile.cxx" #include "referenceCount.cxx" -#include "reMutex.cxx" -#include "reMutexHolder.cxx" #include "reversedNumericData.cxx" #include "streamReader.cxx" #include "streamWriter.cxx" @@ -21,11 +8,6 @@ #include "subStream.cxx" #include "subStreamBuf.cxx" #include "textEncoder.cxx" -#include "thread.cxx" -#include "threadDummyImpl.cxx" -#include "threadNsprImpl.cxx" -#include "threadPosixImpl.cxx" -#include "threadWin32Impl.cxx" #include "trueClock.cxx" #include "typedReferenceCount.cxx" #include "unicodeLatinMap.cxx" diff --git a/panda/src/express/memoryUsage.cxx b/panda/src/express/memoryUsage.cxx index 0c3946282a..248064dd81 100644 --- a/panda/src/express/memoryUsage.cxx +++ b/panda/src/express/memoryUsage.cxx @@ -474,13 +474,13 @@ ns_record_pointer(ReferenceCount *ptr) { info._ref_ptr = ptr; info._static_type = ReferenceCount::get_class_type(); info._dynamic_type = ReferenceCount::get_class_type(); - info._time = TrueClock::get_ptr()->get_long_time(); + info._time = TrueClock::get_global_ptr()->get_long_time(); info._freeze_index = _freeze_index; info._flags |= (MemoryInfo::F_reconsider_dynamic_type | MemoryInfo::F_got_ref); // We close the recursion_protect flag all the way down here, so // that we also protect ourselves against a possible recursive - // call in TrueClock::get_ptr(). + // call in TrueClock::get_global_ptr(). _recursion_protect = false; } } @@ -582,7 +582,7 @@ ns_remove_pointer(ReferenceCount *ptr) { info._typed_ptr = (TypedObject *)NULL; if (info._freeze_index == _freeze_index) { - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); // We have to protect modifications to the table from recursive // calls by toggling _recursion_protect while we adjust it. @@ -654,13 +654,13 @@ ns_record_void_pointer(void *ptr, size_t size) { info._void_ptr = ptr; info._size = size; - info._time = TrueClock::get_ptr()->get_long_time(); + info._time = TrueClock::get_global_ptr()->get_long_time(); info._freeze_index = _freeze_index; info._flags |= (MemoryInfo::F_got_void | MemoryInfo::F_size_known); // We close the recursion_protect flag all the way down here, so // that we also protect ourselves against a possible recursive - // call in TrueClock::get_ptr(). + // call in TrueClock::get_global_ptr(). _recursion_protect = false; } } @@ -806,7 +806,7 @@ ns_get_pointers(MemoryUsagePointers &result) { nassertv(_track_memory_usage); result.clear(); - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { MemoryInfo &info = (*ti).second; @@ -830,7 +830,7 @@ ns_get_pointers_of_type(MemoryUsagePointers &result, TypeHandle type) { nassertv(_track_memory_usage); result.clear(); - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { MemoryInfo &info = (*ti).second; @@ -859,7 +859,7 @@ ns_get_pointers_of_age(MemoryUsagePointers &result, nassertv(_track_memory_usage); result.clear(); - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { MemoryInfo &info = (*ti).second; @@ -902,7 +902,7 @@ ns_get_pointers_with_zero_count(MemoryUsagePointers &result) { nassertv(_track_memory_usage); result.clear(); - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { MemoryInfo &info = (*ti).second; @@ -990,7 +990,7 @@ ns_show_current_ages() { _recursion_protect = true; AgeHistogram hist; - double now = TrueClock::get_ptr()->get_long_time(); + double now = TrueClock::get_global_ptr()->get_long_time(); Table::iterator ti; for (ti = _table.begin(); ti != _table.end(); ++ti) { diff --git a/panda/src/express/profileTimer.I b/panda/src/express/profileTimer.I index 9409f6a182..b5741df216 100644 --- a/panda/src/express/profileTimer.I +++ b/panda/src/express/profileTimer.I @@ -18,13 +18,13 @@ INLINE void ProfileTimer:: on() { - _on = TrueClock::get_ptr()->get_short_time(); + _on = TrueClock::get_global_ptr()->get_short_time(); } INLINE double ProfileTimer:: getTime() { - double time = TrueClock::get_ptr()->get_short_time(); + double time = TrueClock::get_global_ptr()->get_short_time(); double et=_elapsedTime+=time-_on; _on=time; _elapsedTime=0.0; @@ -51,14 +51,14 @@ mark(const char* tag) { INLINE void ProfileTimer:: off() { - double time = TrueClock::get_ptr()->get_short_time(); + double time = TrueClock::get_global_ptr()->get_short_time(); _elapsedTime+=time-_on; } INLINE void ProfileTimer:: off(const char* tag) { - double time = TrueClock::get_ptr()->get_short_time(); + double time = TrueClock::get_global_ptr()->get_short_time(); _elapsedTime+=time-_on; mark(tag); } diff --git a/panda/src/express/trueClock.I b/panda/src/express/trueClock.I index 6e253830a8..be206acf79 100644 --- a/panda/src/express/trueClock.I +++ b/panda/src/express/trueClock.I @@ -16,23 +16,9 @@ // //////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -// Function: TrueClock::get_ptr -// Access: Public -// Description: Returns a pointer to the one TrueClock object in -// the world. -//////////////////////////////////////////////////////////////////// -INLINE TrueClock *TrueClock:: -get_ptr() { - if (_global_ptr == (TrueClock *)NULL) { - _global_ptr = new TrueClock; - } - return _global_ptr; -} - //////////////////////////////////////////////////////////////////// // Function: TrueClock::get_error_count -// Access: Public +// Access: Published // Description: Returns the number of clock errors that have // been detected. Each time a clock error is detected, // in which the value returned by either of the above @@ -46,6 +32,20 @@ get_error_count() const { return _error_count; } +//////////////////////////////////////////////////////////////////// +// Function: TrueClock::get_global_ptr +// Access: Published, Static +// Description: Returns a pointer to the one TrueClock object in +// the world. +//////////////////////////////////////////////////////////////////// +INLINE TrueClock *TrueClock:: +get_global_ptr() { + if (_global_ptr == (TrueClock *)NULL) { + _global_ptr = new TrueClock; + } + return _global_ptr; +} + //////////////////////////////////////////////////////////////////// // Function: TrueClock::Destructor // Access: Protected diff --git a/panda/src/express/trueClock.h b/panda/src/express/trueClock.h index 132484e633..d1691b454d 100644 --- a/panda/src/express/trueClock.h +++ b/panda/src/express/trueClock.h @@ -38,9 +38,7 @@ // and subtracting. //////////////////////////////////////////////////////////////////// class EXPCL_PANDAEXPRESS TrueClock { -public: - INLINE static TrueClock *get_ptr(); - +PUBLISHED: // get_long_time() returns the most accurate timer we have over a // long interval. It may not be very precise for measuring short // intervals, but it should not drift substantially over the long @@ -55,6 +53,8 @@ public: INLINE int get_error_count() const; + INLINE static TrueClock *get_global_ptr(); + protected: TrueClock(); INLINE ~TrueClock(); diff --git a/panda/src/pipeline/Sources.pp b/panda/src/pipeline/Sources.pp new file mode 100644 index 0000000000..7e197aebc3 --- /dev/null +++ b/panda/src/pipeline/Sources.pp @@ -0,0 +1,159 @@ +#define LOCAL_LIBS express pandabase +#define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ + dtoolutil:c dtoolbase:c dtool:m prc:c + +#begin lib_target + #define TARGET pipeline + + #define COMBINED_SOURCES $[TARGET]_composite1.cxx $[TARGET]_composite2.cxx + + #define SOURCES \ + atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ + atomicAdjust.I atomicAdjustImpl.h \ + atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ + atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ + atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ + conditionVar.h conditionVar.I \ + conditionVarDebug.h conditionVarDebug.I \ + conditionVarDirect.h conditionVarDirect.I \ + conditionVarDummyImpl.h conditionVarDummyImpl.I \ + conditionVarImpl.h \ + conditionVarNsprImpl.h conditionVarNsprImpl.I \ + conditionVarPosixImpl.h conditionVarPosixImpl.I \ + conditionVarWin32Impl.h conditionVarWin32Impl.I \ + config_pipeline.h \ + cycleData.h cycleData.I \ + cycleDataReader.h cycleDataReader.I \ + cycleDataStageReader.h cycleDataStageReader.I \ + cycleDataStageWriter.h cycleDataStageWriter.I \ + cycleDataWriter.h cycleDataWriter.I \ + cyclerHolder.h cyclerHolder.I \ + externalThread.h \ + mainThread.h \ + mutexDebug.h mutexDebug.I \ + mutexDirect.h mutexDirect.I \ + mutexHolder.h mutexHolder.I \ + pipeline.h pipeline.I \ + pipelineCycler.h pipelineCycler.I \ + pipelineCyclerLinks.h pipelineCyclerLinks.I \ + pipelineCyclerBase.h \ + pipelineCyclerDummyImpl.h pipelineCyclerDummyImpl.I \ + pipelineCyclerTrivialImpl.h pipelineCyclerTrivialImpl.I \ + pipelineCyclerTrueImpl.h pipelineCyclerTrueImpl.I \ + pmutex.h pmutex.I \ + reMutex.I reMutex.h \ + reMutexDirect.h reMutexDirect.I \ + reMutexHolder.I reMutexHolder.h \ + threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ + threadNsprImpl.h threadNsprImpl.I \ + threadPosixImpl.h threadPosixImpl.I \ + threadWin32Impl.h threadWin32Impl.I \ + threadPriority.h + + #define INCLUDED_SOURCES \ + atomicAdjust.cxx atomicAdjustDummyImpl.cxx \ + atomicAdjustNsprImpl.cxx \ + atomicAdjustPosixImpl.cxx \ + atomicAdjustWin32Impl.cxx \ + conditionVar.cxx \ + conditionVarDebug.cxx \ + conditionVarDirect.cxx \ + conditionVarDummyImpl.cxx \ + conditionVarNsprImpl.cxx \ + conditionVarPosixImpl.cxx \ + conditionVarWin32Impl.cxx \ + config_pipeline.cxx \ + cycleData.cxx \ + cycleDataReader.cxx \ + cycleDataStageReader.cxx \ + cycleDataStageWriter.cxx \ + cycleDataWriter.cxx \ + cyclerHolder.cxx \ + externalThread.cxx \ + mainThread.cxx \ + mutexDebug.cxx \ + mutexDirect.cxx \ + mutexHolder.cxx \ + pipeline.cxx \ + pipelineCycler.cxx \ + pipelineCyclerDummyImpl.cxx \ + pipelineCyclerTrivialImpl.cxx \ + pipelineCyclerTrueImpl.cxx \ + pmutex.cxx \ + reMutex.cxx \ + reMutexDirect.cxx \ + reMutexHolder.cxx \ + thread.cxx threadDummyImpl.cxx \ + threadNsprImpl.cxx \ + threadPosixImpl.cxx \ + threadWin32Impl.cxx + + #define INSTALL_HEADERS \ + atomicAdjustDummyImpl.h atomicAdjustDummyImpl.I atomicAdjust.h \ + atomicAdjust.I atomicAdjustImpl.h \ + atomicAdjustNsprImpl.h atomicAdjustNsprImpl.I \ + atomicAdjustPosixImpl.h atomicAdjustPosixImpl.I \ + atomicAdjustWin32Impl.h atomicAdjustWin32Impl.I \ + conditionVar.h conditionVar.I \ + conditionVarDebug.h conditionVarDebug.I \ + conditionVarDirect.h conditionVarDirect.I \ + conditionVarDummyImpl.h conditionVarDummyImpl.I \ + conditionVarImpl.h \ + conditionVarNsprImpl.h conditionVarNsprImpl.I \ + conditionVarPosixImpl.h conditionVarPosixImpl.I \ + conditionVarWin32Impl.h conditionVarWin32Impl.I \ + config_pipeline.h \ + cycleData.h cycleData.I \ + cycleDataReader.h cycleDataReader.I \ + cycleDataStageReader.h cycleDataStageReader.I \ + cycleDataStageWriter.h cycleDataStageWriter.I \ + cycleDataWriter.h cycleDataWriter.I \ + cyclerHolder.h cyclerHolder.I \ + externalThread.h \ + mainThread.h \ + mutexDebug.h mutexDebug.I \ + mutexDirect.h mutexDirect.I \ + mutexHolder.h mutexHolder.I \ + pipeline.h pipeline.I \ + pipelineCycler.h pipelineCycler.I \ + pipelineCyclerLinks.h pipelineCyclerLinks.I \ + pipelineCyclerBase.h \ + pipelineCyclerDummyImpl.h pipelineCyclerDummyImpl.I \ + pipelineCyclerTrivialImpl.h pipelineCyclerTrivialImpl.I \ + pipelineCyclerTrueImpl.h pipelineCyclerTrueImpl.I \ + pmutex.h pmutex.I \ + reMutex.I reMutex.h \ + reMutexDirect.h reMutexDirect.I \ + reMutexHolder.I reMutexHolder.h \ + threadDummyImpl.h threadDummyImpl.I thread.h thread.I threadImpl.h \ + threadNsprImpl.h threadNsprImpl.I \ + threadPosixImpl.h threadPosixImpl.I \ + threadWin32Impl.h threadWin32Impl.I \ + threadPriority.h + + #define IGATESCAN all + +#end lib_target + + +#begin test_bin_target + #define TARGET test_threaddata + #define LOCAL_LIBS $[LOCAL_LIBS] express + #define OTHER_LIBS dtoolutil:c dtool:m pystub + + #define SOURCES \ + test_threaddata.cxx + +#end test_bin_target + + +#begin test_bin_target + #define TARGET test_diners + #define LOCAL_LIBS $[LOCAL_LIBS] express + #define OTHER_LIBS dtoolutil:c dtool:m dtoolconfig:m pystub + + #define SOURCES \ + test_diners.cxx + +#end test_bin_target + diff --git a/panda/src/express/atomicAdjust.I b/panda/src/pipeline/atomicAdjust.I similarity index 100% rename from panda/src/express/atomicAdjust.I rename to panda/src/pipeline/atomicAdjust.I diff --git a/panda/src/express/atomicAdjust.cxx b/panda/src/pipeline/atomicAdjust.cxx similarity index 100% rename from panda/src/express/atomicAdjust.cxx rename to panda/src/pipeline/atomicAdjust.cxx diff --git a/panda/src/express/atomicAdjust.h b/panda/src/pipeline/atomicAdjust.h similarity index 97% rename from panda/src/express/atomicAdjust.h rename to panda/src/pipeline/atomicAdjust.h index f1fcbc12e0..e05c764560 100644 --- a/panda/src/express/atomicAdjust.h +++ b/panda/src/pipeline/atomicAdjust.h @@ -30,7 +30,7 @@ // others to guarantee that a multibyte value is changed // in one atomic operation. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjust { +class EXPCL_PANDA AtomicAdjust { public: INLINE static PN_int32 inc(PN_int32 &var); INLINE static PN_int32 dec(PN_int32 &var); diff --git a/panda/src/express/atomicAdjustDummyImpl.I b/panda/src/pipeline/atomicAdjustDummyImpl.I similarity index 100% rename from panda/src/express/atomicAdjustDummyImpl.I rename to panda/src/pipeline/atomicAdjustDummyImpl.I diff --git a/panda/src/express/atomicAdjustDummyImpl.cxx b/panda/src/pipeline/atomicAdjustDummyImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustDummyImpl.cxx rename to panda/src/pipeline/atomicAdjustDummyImpl.cxx diff --git a/panda/src/express/atomicAdjustDummyImpl.h b/panda/src/pipeline/atomicAdjustDummyImpl.h similarity index 96% rename from panda/src/express/atomicAdjustDummyImpl.h rename to panda/src/pipeline/atomicAdjustDummyImpl.h index 74ef86eaa4..9d4b06fcde 100644 --- a/panda/src/express/atomicAdjustDummyImpl.h +++ b/panda/src/pipeline/atomicAdjustDummyImpl.h @@ -33,7 +33,7 @@ // systems that don't require multiprogramming, and // therefore don't require special atomic operations. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustDummyImpl { +class EXPCL_PANDA AtomicAdjustDummyImpl { public: INLINE static PN_int32 inc(PN_int32 &var); INLINE static PN_int32 dec(PN_int32 &var); diff --git a/panda/src/express/atomicAdjustImpl.h b/panda/src/pipeline/atomicAdjustImpl.h similarity index 100% rename from panda/src/express/atomicAdjustImpl.h rename to panda/src/pipeline/atomicAdjustImpl.h diff --git a/panda/src/express/atomicAdjustNsprImpl.I b/panda/src/pipeline/atomicAdjustNsprImpl.I similarity index 100% rename from panda/src/express/atomicAdjustNsprImpl.I rename to panda/src/pipeline/atomicAdjustNsprImpl.I diff --git a/panda/src/express/atomicAdjustNsprImpl.cxx b/panda/src/pipeline/atomicAdjustNsprImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustNsprImpl.cxx rename to panda/src/pipeline/atomicAdjustNsprImpl.cxx diff --git a/panda/src/express/atomicAdjustNsprImpl.h b/panda/src/pipeline/atomicAdjustNsprImpl.h similarity index 96% rename from panda/src/express/atomicAdjustNsprImpl.h rename to panda/src/pipeline/atomicAdjustNsprImpl.h index 2df1afe8ff..80bad055df 100644 --- a/panda/src/express/atomicAdjustNsprImpl.h +++ b/panda/src/pipeline/atomicAdjustNsprImpl.h @@ -33,7 +33,7 @@ // Class : AtomicAdjustNsprImpl // Description : Uses NSPR to implement atomic adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustNsprImpl { +class EXPCL_PANDA AtomicAdjustNsprImpl { public: INLINE static PN_int32 inc(PN_int32 &var); INLINE static PN_int32 dec(PN_int32 &var); diff --git a/panda/src/express/atomicAdjustPosixImpl.I b/panda/src/pipeline/atomicAdjustPosixImpl.I similarity index 100% rename from panda/src/express/atomicAdjustPosixImpl.I rename to panda/src/pipeline/atomicAdjustPosixImpl.I diff --git a/panda/src/express/atomicAdjustPosixImpl.cxx b/panda/src/pipeline/atomicAdjustPosixImpl.cxx similarity index 100% rename from panda/src/express/atomicAdjustPosixImpl.cxx rename to panda/src/pipeline/atomicAdjustPosixImpl.cxx diff --git a/panda/src/express/atomicAdjustPosixImpl.h b/panda/src/pipeline/atomicAdjustPosixImpl.h similarity index 96% rename from panda/src/express/atomicAdjustPosixImpl.h rename to panda/src/pipeline/atomicAdjustPosixImpl.h index 4fe882a22d..e761be1f44 100644 --- a/panda/src/express/atomicAdjustPosixImpl.h +++ b/panda/src/pipeline/atomicAdjustPosixImpl.h @@ -33,7 +33,7 @@ // Class : AtomicAdjustPosixImpl // Description : Uses POSIX to implement atomic adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustPosixImpl { +class EXPCL_PANDA AtomicAdjustPosixImpl { public: INLINE static PN_int32 inc(PN_int32 &var); INLINE static PN_int32 dec(PN_int32 &var); diff --git a/panda/src/express/atomicAdjustWin32Impl.I b/panda/src/pipeline/atomicAdjustWin32Impl.I similarity index 100% rename from panda/src/express/atomicAdjustWin32Impl.I rename to panda/src/pipeline/atomicAdjustWin32Impl.I diff --git a/panda/src/express/atomicAdjustWin32Impl.cxx b/panda/src/pipeline/atomicAdjustWin32Impl.cxx similarity index 100% rename from panda/src/express/atomicAdjustWin32Impl.cxx rename to panda/src/pipeline/atomicAdjustWin32Impl.cxx diff --git a/panda/src/express/atomicAdjustWin32Impl.h b/panda/src/pipeline/atomicAdjustWin32Impl.h similarity index 96% rename from panda/src/express/atomicAdjustWin32Impl.h rename to panda/src/pipeline/atomicAdjustWin32Impl.h index 9bbd1625b2..81bd8cac00 100644 --- a/panda/src/express/atomicAdjustWin32Impl.h +++ b/panda/src/pipeline/atomicAdjustWin32Impl.h @@ -34,7 +34,7 @@ // Description : Uses Windows native calls to implement atomic // adjustments. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS AtomicAdjustWin32Impl { +class EXPCL_PANDA AtomicAdjustWin32Impl { public: INLINE static PN_int32 inc(PN_int32 &var); INLINE static PN_int32 dec(PN_int32 &var); diff --git a/panda/src/express/conditionVar.I b/panda/src/pipeline/conditionVar.I similarity index 100% rename from panda/src/express/conditionVar.I rename to panda/src/pipeline/conditionVar.I diff --git a/panda/src/express/conditionVar.cxx b/panda/src/pipeline/conditionVar.cxx similarity index 100% rename from panda/src/express/conditionVar.cxx rename to panda/src/pipeline/conditionVar.cxx diff --git a/panda/src/express/conditionVar.h b/panda/src/pipeline/conditionVar.h similarity index 93% rename from panda/src/express/conditionVar.h rename to panda/src/pipeline/conditionVar.h index f6596dc0a5..799898d491 100644 --- a/panda/src/express/conditionVar.h +++ b/panda/src/pipeline/conditionVar.h @@ -40,9 +40,9 @@ // the definition of DEBUG_THREADS. //////////////////////////////////////////////////////////////////// #ifdef DEBUG_THREADS -class EXPCL_PANDAEXPRESS ConditionVar : public ConditionVarDebug +class EXPCL_PANDA ConditionVar : public ConditionVarDebug #else -class EXPCL_PANDAEXPRESS ConditionVar : public ConditionVarDirect +class EXPCL_PANDA ConditionVar : public ConditionVarDirect #endif // DEBUG_THREADS { public: diff --git a/panda/src/express/conditionVarDebug.I b/panda/src/pipeline/conditionVarDebug.I similarity index 100% rename from panda/src/express/conditionVarDebug.I rename to panda/src/pipeline/conditionVarDebug.I diff --git a/panda/src/express/conditionVarDebug.cxx b/panda/src/pipeline/conditionVarDebug.cxx similarity index 100% rename from panda/src/express/conditionVarDebug.cxx rename to panda/src/pipeline/conditionVarDebug.cxx diff --git a/panda/src/express/conditionVarDebug.h b/panda/src/pipeline/conditionVarDebug.h old mode 100755 new mode 100644 similarity index 97% rename from panda/src/express/conditionVarDebug.h rename to panda/src/pipeline/conditionVarDebug.h index 0441081d5d..6e3f1bf30e --- a/panda/src/express/conditionVarDebug.h +++ b/panda/src/pipeline/conditionVarDebug.h @@ -37,7 +37,7 @@ // mutex, and several condition variables may share the // same mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarDebug { +class EXPCL_PANDA ConditionVarDebug { public: ConditionVarDebug(MutexDebug &mutex); virtual ~ConditionVarDebug(); diff --git a/panda/src/express/conditionVarDirect.I b/panda/src/pipeline/conditionVarDirect.I similarity index 100% rename from panda/src/express/conditionVarDirect.I rename to panda/src/pipeline/conditionVarDirect.I diff --git a/panda/src/express/conditionVarDirect.cxx b/panda/src/pipeline/conditionVarDirect.cxx similarity index 100% rename from panda/src/express/conditionVarDirect.cxx rename to panda/src/pipeline/conditionVarDirect.cxx diff --git a/panda/src/express/conditionVarDirect.h b/panda/src/pipeline/conditionVarDirect.h old mode 100755 new mode 100644 similarity index 97% rename from panda/src/express/conditionVarDirect.h rename to panda/src/pipeline/conditionVarDirect.h index b3c413efdb..3aede6b145 --- a/panda/src/express/conditionVarDirect.h +++ b/panda/src/pipeline/conditionVarDirect.h @@ -37,7 +37,7 @@ // mutex, and several condition variables may share the // same mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarDirect { +class EXPCL_PANDA ConditionVarDirect { public: INLINE ConditionVarDirect(MutexDirect &mutex); INLINE ~ConditionVarDirect(); diff --git a/panda/src/express/conditionVarDummyImpl.I b/panda/src/pipeline/conditionVarDummyImpl.I similarity index 100% rename from panda/src/express/conditionVarDummyImpl.I rename to panda/src/pipeline/conditionVarDummyImpl.I diff --git a/panda/src/express/conditionVarDummyImpl.cxx b/panda/src/pipeline/conditionVarDummyImpl.cxx similarity index 100% rename from panda/src/express/conditionVarDummyImpl.cxx rename to panda/src/pipeline/conditionVarDummyImpl.cxx diff --git a/panda/src/express/conditionVarDummyImpl.h b/panda/src/pipeline/conditionVarDummyImpl.h similarity index 96% rename from panda/src/express/conditionVarDummyImpl.h rename to panda/src/pipeline/conditionVarDummyImpl.h index 5a2d9bdb41..e04e89868e 100644 --- a/panda/src/express/conditionVarDummyImpl.h +++ b/panda/src/pipeline/conditionVarDummyImpl.h @@ -34,7 +34,7 @@ class MutexDummyImpl; // single-threaded applications that don't need any // synchronization control. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarDummyImpl { +class EXPCL_PANDA ConditionVarDummyImpl { public: INLINE ConditionVarDummyImpl(MutexDummyImpl &mutex); INLINE ~ConditionVarDummyImpl(); diff --git a/panda/src/express/conditionVarImpl.h b/panda/src/pipeline/conditionVarImpl.h similarity index 100% rename from panda/src/express/conditionVarImpl.h rename to panda/src/pipeline/conditionVarImpl.h diff --git a/panda/src/express/conditionVarNsprImpl.I b/panda/src/pipeline/conditionVarNsprImpl.I similarity index 100% rename from panda/src/express/conditionVarNsprImpl.I rename to panda/src/pipeline/conditionVarNsprImpl.I diff --git a/panda/src/express/conditionVarNsprImpl.cxx b/panda/src/pipeline/conditionVarNsprImpl.cxx similarity index 100% rename from panda/src/express/conditionVarNsprImpl.cxx rename to panda/src/pipeline/conditionVarNsprImpl.cxx diff --git a/panda/src/express/conditionVarNsprImpl.h b/panda/src/pipeline/conditionVarNsprImpl.h similarity index 96% rename from panda/src/express/conditionVarNsprImpl.h rename to panda/src/pipeline/conditionVarNsprImpl.h index 5dedb2eb7d..4fb77fabc8 100644 --- a/panda/src/express/conditionVarNsprImpl.h +++ b/panda/src/pipeline/conditionVarNsprImpl.h @@ -35,7 +35,7 @@ class MutexNsprImpl; // Class : ConditionVarNsprImpl // Description : Uses NSPR to implement a conditionVar. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarNsprImpl { +class EXPCL_PANDA ConditionVarNsprImpl { public: INLINE ConditionVarNsprImpl(MutexNsprImpl &mutex); INLINE ~ConditionVarNsprImpl(); diff --git a/panda/src/express/conditionVarPosixImpl.I b/panda/src/pipeline/conditionVarPosixImpl.I similarity index 100% rename from panda/src/express/conditionVarPosixImpl.I rename to panda/src/pipeline/conditionVarPosixImpl.I diff --git a/panda/src/express/conditionVarPosixImpl.cxx b/panda/src/pipeline/conditionVarPosixImpl.cxx similarity index 100% rename from panda/src/express/conditionVarPosixImpl.cxx rename to panda/src/pipeline/conditionVarPosixImpl.cxx diff --git a/panda/src/express/conditionVarPosixImpl.h b/panda/src/pipeline/conditionVarPosixImpl.h similarity index 96% rename from panda/src/express/conditionVarPosixImpl.h rename to panda/src/pipeline/conditionVarPosixImpl.h index ccd916a4d5..1451eedd8f 100644 --- a/panda/src/express/conditionVarPosixImpl.h +++ b/panda/src/pipeline/conditionVarPosixImpl.h @@ -35,7 +35,7 @@ class MutexPosixImpl; // Class : ConditionVarPosixImpl // Description : Uses Posix threads to implement a conditionVar. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarPosixImpl { +class EXPCL_PANDA ConditionVarPosixImpl { public: INLINE ConditionVarPosixImpl(MutexPosixImpl &mutex); INLINE ~ConditionVarPosixImpl(); diff --git a/panda/src/express/conditionVarWin32Impl.I b/panda/src/pipeline/conditionVarWin32Impl.I similarity index 100% rename from panda/src/express/conditionVarWin32Impl.I rename to panda/src/pipeline/conditionVarWin32Impl.I diff --git a/panda/src/express/conditionVarWin32Impl.cxx b/panda/src/pipeline/conditionVarWin32Impl.cxx similarity index 100% rename from panda/src/express/conditionVarWin32Impl.cxx rename to panda/src/pipeline/conditionVarWin32Impl.cxx diff --git a/panda/src/express/conditionVarWin32Impl.h b/panda/src/pipeline/conditionVarWin32Impl.h similarity index 97% rename from panda/src/express/conditionVarWin32Impl.h rename to panda/src/pipeline/conditionVarWin32Impl.h index 94974352fc..533f3d6513 100644 --- a/panda/src/express/conditionVarWin32Impl.h +++ b/panda/src/pipeline/conditionVarWin32Impl.h @@ -46,7 +46,7 @@ class MutexWin32Impl; // so we can avoid the overhead require to support // broadcast. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ConditionVarWin32Impl { +class EXPCL_PANDA ConditionVarWin32Impl { public: INLINE ConditionVarWin32Impl(MutexWin32Impl &mutex); INLINE ~ConditionVarWin32Impl(); diff --git a/panda/src/pipeline/config_pipeline.cxx b/panda/src/pipeline/config_pipeline.cxx new file mode 100644 index 0000000000..58952c7971 --- /dev/null +++ b/panda/src/pipeline/config_pipeline.cxx @@ -0,0 +1,61 @@ +// Filename: config_pipeline.cxx +// Created by: drose (28Mar06) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#include "config_pipeline.h" +#include "mainThread.h" +#include "externalThread.h" +#include "thread.h" +#include "pandaSystem.h" + +#include "dconfig.h" + +ConfigureDef(config_pipeline); +NotifyCategoryDef(pipeline, ""); +NotifyCategoryDef(thread, ""); + +ConfigureFn(config_pipeline) { + init_libpipeline(); +} + +//////////////////////////////////////////////////////////////////// +// Function: init_libpipeline +// Description: Initializes the library. This must be called at +// least once before any of the functions or classes in +// this library can be used. Normally it will be +// called by the static initializers and need not be +// called explicitly, but special cases exist. +//////////////////////////////////////////////////////////////////// +void +init_libpipeline() { + static bool initialized = false; + if (initialized) { + return; + } + initialized = true; + + MainThread::init_type(); + ExternalThread::init_type(); + Thread::init_type(); + +#ifdef HAVE_THREADS + { + PandaSystem *ps = PandaSystem::get_global_ptr(); + ps->add_system("threads"); + } +#endif +} diff --git a/panda/src/pipeline/config_pipeline.h b/panda/src/pipeline/config_pipeline.h new file mode 100644 index 0000000000..95d956d673 --- /dev/null +++ b/panda/src/pipeline/config_pipeline.h @@ -0,0 +1,33 @@ +// Filename: config_pipeline.h +// Created by: cary (04Jan00) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef CONFIG_PIPELINE_H +#define CONFIG_PIPELINE_H + +#include "pandabase.h" +#include "notifyCategoryProxy.h" +#include "dconfig.h" + +ConfigureDecl(config_pipeline, EXPCL_PANDA, EXPTP_PANDA); +NotifyCategoryDecl(pipeline, EXPCL_PANDA, EXPTP_PANDA); +NotifyCategoryDecl(thread, EXPCL_PANDA, EXPTP_PANDA); + +extern EXPCL_PANDA void init_libpipeline(); + +#endif // CONFIG_PIPELINE_H + diff --git a/panda/src/express/cycleData.I b/panda/src/pipeline/cycleData.I similarity index 100% rename from panda/src/express/cycleData.I rename to panda/src/pipeline/cycleData.I diff --git a/panda/src/express/cycleData.cxx b/panda/src/pipeline/cycleData.cxx similarity index 100% rename from panda/src/express/cycleData.cxx rename to panda/src/pipeline/cycleData.cxx diff --git a/panda/src/express/cycleData.h b/panda/src/pipeline/cycleData.h similarity index 96% rename from panda/src/express/cycleData.h rename to panda/src/pipeline/cycleData.h index 47c9f91b6f..45d1cc814a 100644 --- a/panda/src/express/cycleData.h +++ b/panda/src/pipeline/cycleData.h @@ -41,14 +41,14 @@ class DatagramIterator; // If we are compiling in pipelining support, we maintain a pointer to // a CycleData object in each containing class, instead of the object // itself. Thus, it should be a ReferenceCount object. -class EXPCL_PANDAEXPRESS CycleData : public ReferenceCount +class EXPCL_PANDA CycleData : public ReferenceCount #else // !DO_PIPELINING // If we are *not* compiling in pipelining support, the CycleData // object is stored directly within its containing classes, and hence // should not be a ReferenceCount object. -class EXPCL_PANDAEXPRESS CycleData +class EXPCL_PANDA CycleData #endif // DO_PIPELINING { diff --git a/panda/src/express/cycleDataReader.I b/panda/src/pipeline/cycleDataReader.I similarity index 100% rename from panda/src/express/cycleDataReader.I rename to panda/src/pipeline/cycleDataReader.I diff --git a/panda/src/express/cycleDataReader.cxx b/panda/src/pipeline/cycleDataReader.cxx similarity index 100% rename from panda/src/express/cycleDataReader.cxx rename to panda/src/pipeline/cycleDataReader.cxx diff --git a/panda/src/express/cycleDataReader.h b/panda/src/pipeline/cycleDataReader.h similarity index 100% rename from panda/src/express/cycleDataReader.h rename to panda/src/pipeline/cycleDataReader.h diff --git a/panda/src/express/cycleDataStageReader.I b/panda/src/pipeline/cycleDataStageReader.I similarity index 100% rename from panda/src/express/cycleDataStageReader.I rename to panda/src/pipeline/cycleDataStageReader.I diff --git a/panda/src/express/cycleDataStageReader.cxx b/panda/src/pipeline/cycleDataStageReader.cxx similarity index 100% rename from panda/src/express/cycleDataStageReader.cxx rename to panda/src/pipeline/cycleDataStageReader.cxx diff --git a/panda/src/express/cycleDataStageReader.h b/panda/src/pipeline/cycleDataStageReader.h similarity index 100% rename from panda/src/express/cycleDataStageReader.h rename to panda/src/pipeline/cycleDataStageReader.h diff --git a/panda/src/express/cycleDataStageWriter.I b/panda/src/pipeline/cycleDataStageWriter.I similarity index 100% rename from panda/src/express/cycleDataStageWriter.I rename to panda/src/pipeline/cycleDataStageWriter.I diff --git a/panda/src/express/cycleDataStageWriter.cxx b/panda/src/pipeline/cycleDataStageWriter.cxx similarity index 100% rename from panda/src/express/cycleDataStageWriter.cxx rename to panda/src/pipeline/cycleDataStageWriter.cxx diff --git a/panda/src/express/cycleDataStageWriter.h b/panda/src/pipeline/cycleDataStageWriter.h similarity index 100% rename from panda/src/express/cycleDataStageWriter.h rename to panda/src/pipeline/cycleDataStageWriter.h diff --git a/panda/src/express/cycleDataWriter.I b/panda/src/pipeline/cycleDataWriter.I similarity index 100% rename from panda/src/express/cycleDataWriter.I rename to panda/src/pipeline/cycleDataWriter.I diff --git a/panda/src/express/cycleDataWriter.cxx b/panda/src/pipeline/cycleDataWriter.cxx similarity index 100% rename from panda/src/express/cycleDataWriter.cxx rename to panda/src/pipeline/cycleDataWriter.cxx diff --git a/panda/src/express/cycleDataWriter.h b/panda/src/pipeline/cycleDataWriter.h similarity index 100% rename from panda/src/express/cycleDataWriter.h rename to panda/src/pipeline/cycleDataWriter.h diff --git a/panda/src/express/cyclerHolder.I b/panda/src/pipeline/cyclerHolder.I similarity index 100% rename from panda/src/express/cyclerHolder.I rename to panda/src/pipeline/cyclerHolder.I diff --git a/panda/src/express/cyclerHolder.cxx b/panda/src/pipeline/cyclerHolder.cxx similarity index 100% rename from panda/src/express/cyclerHolder.cxx rename to panda/src/pipeline/cyclerHolder.cxx diff --git a/panda/src/express/cyclerHolder.h b/panda/src/pipeline/cyclerHolder.h similarity index 97% rename from panda/src/express/cyclerHolder.h rename to panda/src/pipeline/cyclerHolder.h index 5ae85fb0ef..b8d03e7d94 100644 --- a/panda/src/express/cyclerHolder.h +++ b/panda/src/pipeline/cyclerHolder.h @@ -29,7 +29,7 @@ // PipelineCyclerBase object. This is similar to a // MutexHolder. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS CyclerHolder { +class EXPCL_PANDA CyclerHolder { public: INLINE CyclerHolder(PipelineCyclerBase &cycler); INLINE ~CyclerHolder(); diff --git a/panda/src/express/externalThread.cxx b/panda/src/pipeline/externalThread.cxx similarity index 100% rename from panda/src/express/externalThread.cxx rename to panda/src/pipeline/externalThread.cxx diff --git a/panda/src/express/externalThread.h b/panda/src/pipeline/externalThread.h similarity index 96% rename from panda/src/express/externalThread.h rename to panda/src/pipeline/externalThread.h index 312a9002c8..5aba1c31d2 100644 --- a/panda/src/express/externalThread.h +++ b/panda/src/pipeline/externalThread.h @@ -28,7 +28,7 @@ // instance of these in the world, and it is returned by // Thread::get_external_thread(). //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ExternalThread : public Thread { +class EXPCL_PANDA ExternalThread : public Thread { private: ExternalThread(); ExternalThread(const string &name, const string &sync_name); diff --git a/panda/src/express/mainThread.cxx b/panda/src/pipeline/mainThread.cxx similarity index 100% rename from panda/src/express/mainThread.cxx rename to panda/src/pipeline/mainThread.cxx diff --git a/panda/src/express/mainThread.h b/panda/src/pipeline/mainThread.h similarity index 96% rename from panda/src/express/mainThread.h rename to panda/src/pipeline/mainThread.h index d830921a0f..f11c65f688 100644 --- a/panda/src/express/mainThread.h +++ b/panda/src/pipeline/mainThread.h @@ -28,7 +28,7 @@ // instance of these in the world, and it is returned by // Thread::get_main_thread(). //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS MainThread : public Thread { +class EXPCL_PANDA MainThread : public Thread { private: MainThread(); virtual void thread_main(); diff --git a/panda/src/express/mutexDebug.I b/panda/src/pipeline/mutexDebug.I similarity index 100% rename from panda/src/express/mutexDebug.I rename to panda/src/pipeline/mutexDebug.I diff --git a/panda/src/express/mutexDebug.cxx b/panda/src/pipeline/mutexDebug.cxx similarity index 82% rename from panda/src/express/mutexDebug.cxx rename to panda/src/pipeline/mutexDebug.cxx index 8a36e5df63..ffa5ef9981 100755 --- a/panda/src/express/mutexDebug.cxx +++ b/panda/src/pipeline/mutexDebug.cxx @@ -18,9 +18,13 @@ #include "mutexDebug.h" #include "thread.h" +#include "config_pipeline.h" #ifdef DEBUG_THREADS +MutexDebug::VoidFunc *MutexDebug::_pstats_wait_start; +MutexDebug::VoidFunc *MutexDebug::_pstats_wait_stop; + MutexImpl MutexDebug::_global_mutex; //////////////////////////////////////////////////////////////////// @@ -52,6 +56,24 @@ output(ostream &out) const { } } +//////////////////////////////////////////////////////////////////// +// Function: MutexDebug::set_pstats_callbacks +// Access: Public, Static +// Description: This special function exists to provide hooks into +// the PStatClient system, so we can time the amount of +// time we spend waiting for a mutex lock (if the user +// configures this on). We have to do this nutty void +// function callback thing, because PStats is defined in +// a later module (it depends on this module, because it +// needs to use mutex locks, of course). +//////////////////////////////////////////////////////////////////// +void MutexDebug:: +set_pstats_callbacks(MutexDebug::VoidFunc *wait_start, + MutexDebug::VoidFunc *wait_stop) { + _pstats_wait_start = wait_start; + _pstats_wait_stop = wait_stop; +} + //////////////////////////////////////////////////////////////////// // Function: MutexDebug::do_lock // Access: Private @@ -86,14 +108,27 @@ do_lock() { ++_lock_count; } else { - // The mutex is locked by some other thread. Check for deadlock? - MutexDebug *next_mutex = this; + // The mutex is locked by some other thread. +#ifdef DO_PSTATS + if (_pstats_wait_start != NULL) { + (*_pstats_wait_start)(); + } +#endif // DO_PSTATS + // Check for deadlock. + MutexDebug *next_mutex = this; while (next_mutex != NULL) { if (next_mutex->_locking_thread == this_thread) { // Whoops, the thread is blocked on me! Deadlock! report_deadlock(this_thread); nassert_raise("Deadlock"); + +#ifdef DO_PSTATS + if (_pstats_wait_stop != NULL) { + (*_pstats_wait_stop)(); + } +#endif // DO_PSTATS + _global_mutex.release(); return; } @@ -122,6 +157,7 @@ do_lock() { while (_locking_thread != (Thread *)NULL) { _cvar.wait(); } + if (thread_cat.is_spam()) { thread_cat.spam() << *this_thread << " awake\n"; @@ -132,7 +168,13 @@ do_lock() { _locking_thread = this_thread; ++_lock_count; nassertv(_lock_count == 1); - } + + #ifdef DO_PSTATS + if (_pstats_wait_stop != NULL) { + (*_pstats_wait_stop)(); + } +#endif // DO_PSTATS + } } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/mutexDebug.h b/panda/src/pipeline/mutexDebug.h old mode 100755 new mode 100644 similarity index 90% rename from panda/src/express/mutexDebug.h rename to panda/src/pipeline/mutexDebug.h index f00bcc979b..83c2c83fc1 --- a/panda/src/express/mutexDebug.h +++ b/panda/src/pipeline/mutexDebug.h @@ -33,7 +33,7 @@ class Thread; // by doing everything by hand. This does allow fancy // things like deadlock detection, however. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS MutexDebug { +class EXPCL_PANDA MutexDebug { protected: INLINE MutexDebug(bool allow_recursion); virtual ~MutexDebug(); @@ -48,6 +48,9 @@ public: virtual void output(ostream &out) const; + typedef void VoidFunc(); + static void set_pstats_callbacks(VoidFunc *wait_start, VoidFunc *wait_stop); + private: void do_lock(); void do_release(); @@ -61,6 +64,8 @@ private: int _lock_count; ConditionVarImpl _cvar; + static VoidFunc *_pstats_wait_start, *_pstats_wait_stop; + static MutexImpl _global_mutex; friend class ConditionVarDebug; diff --git a/panda/src/express/mutexDirect.I b/panda/src/pipeline/mutexDirect.I similarity index 100% rename from panda/src/express/mutexDirect.I rename to panda/src/pipeline/mutexDirect.I diff --git a/panda/src/express/mutexDirect.cxx b/panda/src/pipeline/mutexDirect.cxx similarity index 100% rename from panda/src/express/mutexDirect.cxx rename to panda/src/pipeline/mutexDirect.cxx diff --git a/panda/src/express/mutexDirect.h b/panda/src/pipeline/mutexDirect.h old mode 100755 new mode 100644 similarity index 97% rename from panda/src/express/mutexDirect.h rename to panda/src/pipeline/mutexDirect.h index 9aac0cb0b5..7796b1e382 --- a/panda/src/express/mutexDirect.h +++ b/panda/src/pipeline/mutexDirect.h @@ -32,7 +32,7 @@ class Thread; // direct calls to the underlying implementation layer. // It doesn't perform any debugging operations. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS MutexDirect { +class EXPCL_PANDA MutexDirect { protected: INLINE MutexDirect(); INLINE ~MutexDirect(); diff --git a/panda/src/express/mutexHolder.I b/panda/src/pipeline/mutexHolder.I similarity index 100% rename from panda/src/express/mutexHolder.I rename to panda/src/pipeline/mutexHolder.I diff --git a/panda/src/express/mutexHolder.cxx b/panda/src/pipeline/mutexHolder.cxx similarity index 100% rename from panda/src/express/mutexHolder.cxx rename to panda/src/pipeline/mutexHolder.cxx diff --git a/panda/src/express/mutexHolder.h b/panda/src/pipeline/mutexHolder.h similarity index 98% rename from panda/src/express/mutexHolder.h rename to panda/src/pipeline/mutexHolder.h index 98c1c61090..a2678fbd1f 100644 --- a/panda/src/express/mutexHolder.h +++ b/panda/src/pipeline/mutexHolder.h @@ -30,7 +30,7 @@ // release() automatically when a block exits (for // instance, on return). //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS MutexHolder { +class EXPCL_PANDA MutexHolder { public: INLINE MutexHolder(const Mutex &mutex); INLINE MutexHolder(Mutex *&mutex); diff --git a/panda/src/express/pipeline.I b/panda/src/pipeline/pipeline.I similarity index 100% rename from panda/src/express/pipeline.I rename to panda/src/pipeline/pipeline.I diff --git a/panda/src/express/pipeline.cxx b/panda/src/pipeline/pipeline.cxx similarity index 99% rename from panda/src/express/pipeline.cxx rename to panda/src/pipeline/pipeline.cxx index 57bdf7543f..e09015fbe9 100644 --- a/panda/src/express/pipeline.cxx +++ b/panda/src/pipeline/pipeline.cxx @@ -20,7 +20,7 @@ #include "pipelineCyclerTrueImpl.h" #include "reMutexHolder.h" #include "configVariableInt.h" -#include "config_express.h" +#include "config_pipeline.h" Pipeline *Pipeline::_render_pipeline = (Pipeline *)NULL; @@ -199,7 +199,7 @@ set_num_stages(int num_stages) { #else // THREADED_PIPELINE if (num_stages != 1) { - express_cat.warning() + pipeline_cat.warning() << "Requested " << num_stages << " pipeline stages but multithreaded render pipelines not enabled in build.\n"; } diff --git a/panda/src/express/pipeline.h b/panda/src/pipeline/pipeline.h similarity index 97% rename from panda/src/express/pipeline.h rename to panda/src/pipeline/pipeline.h index c4f16d1b23..9b769b0aa6 100644 --- a/panda/src/express/pipeline.h +++ b/panda/src/pipeline/pipeline.h @@ -41,7 +41,7 @@ struct PipelineCyclerTrueImpl; // pipeline. Other specialty pipelines may be created // as needed. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS Pipeline : public PipelineCyclerLinks, public Namable { +class EXPCL_PANDA Pipeline : public PipelineCyclerLinks, public Namable { public: Pipeline(const string &name, int num_stages); ~Pipeline(); diff --git a/panda/src/express/pipelineCycler.I b/panda/src/pipeline/pipelineCycler.I similarity index 100% rename from panda/src/express/pipelineCycler.I rename to panda/src/pipeline/pipelineCycler.I diff --git a/panda/src/express/pipelineCycler.cxx b/panda/src/pipeline/pipelineCycler.cxx similarity index 100% rename from panda/src/express/pipelineCycler.cxx rename to panda/src/pipeline/pipelineCycler.cxx diff --git a/panda/src/express/pipelineCycler.h b/panda/src/pipeline/pipelineCycler.h similarity index 100% rename from panda/src/express/pipelineCycler.h rename to panda/src/pipeline/pipelineCycler.h diff --git a/panda/src/express/pipelineCyclerBase.h b/panda/src/pipeline/pipelineCyclerBase.h similarity index 100% rename from panda/src/express/pipelineCyclerBase.h rename to panda/src/pipeline/pipelineCyclerBase.h diff --git a/panda/src/express/pipelineCyclerDummyImpl.I b/panda/src/pipeline/pipelineCyclerDummyImpl.I similarity index 100% rename from panda/src/express/pipelineCyclerDummyImpl.I rename to panda/src/pipeline/pipelineCyclerDummyImpl.I diff --git a/panda/src/express/pipelineCyclerDummyImpl.cxx b/panda/src/pipeline/pipelineCyclerDummyImpl.cxx similarity index 100% rename from panda/src/express/pipelineCyclerDummyImpl.cxx rename to panda/src/pipeline/pipelineCyclerDummyImpl.cxx diff --git a/panda/src/express/pipelineCyclerDummyImpl.h b/panda/src/pipeline/pipelineCyclerDummyImpl.h similarity index 98% rename from panda/src/express/pipelineCyclerDummyImpl.h rename to panda/src/pipeline/pipelineCyclerDummyImpl.h index 1481450859..33e5206048 100644 --- a/panda/src/express/pipelineCyclerDummyImpl.h +++ b/panda/src/pipeline/pipelineCyclerDummyImpl.h @@ -45,7 +45,7 @@ // mainly to be consistent with // PipelineCyclerTrivialImpl. //////////////////////////////////////////////////////////////////// -struct EXPCL_PANDAEXPRESS PipelineCyclerDummyImpl { +struct EXPCL_PANDA PipelineCyclerDummyImpl { public: INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL); INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl ©); diff --git a/panda/src/express/pipelineCyclerLinks.I b/panda/src/pipeline/pipelineCyclerLinks.I similarity index 100% rename from panda/src/express/pipelineCyclerLinks.I rename to panda/src/pipeline/pipelineCyclerLinks.I diff --git a/panda/src/express/pipelineCyclerLinks.h b/panda/src/pipeline/pipelineCyclerLinks.h similarity index 97% rename from panda/src/express/pipelineCyclerLinks.h rename to panda/src/pipeline/pipelineCyclerLinks.h index be2021ba63..7f88959421 100644 --- a/panda/src/express/pipelineCyclerLinks.h +++ b/panda/src/pipeline/pipelineCyclerLinks.h @@ -36,7 +36,7 @@ // so the Pipeline object itself can be the root of the // linked list. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS PipelineCyclerLinks { +class EXPCL_PANDA PipelineCyclerLinks { protected: #ifdef THREADED_PIPELINE INLINE PipelineCyclerLinks(); diff --git a/panda/src/express/pipelineCyclerTrivialImpl.I b/panda/src/pipeline/pipelineCyclerTrivialImpl.I similarity index 100% rename from panda/src/express/pipelineCyclerTrivialImpl.I rename to panda/src/pipeline/pipelineCyclerTrivialImpl.I diff --git a/panda/src/express/pipelineCyclerTrivialImpl.cxx b/panda/src/pipeline/pipelineCyclerTrivialImpl.cxx similarity index 100% rename from panda/src/express/pipelineCyclerTrivialImpl.cxx rename to panda/src/pipeline/pipelineCyclerTrivialImpl.cxx diff --git a/panda/src/express/pipelineCyclerTrivialImpl.h b/panda/src/pipeline/pipelineCyclerTrivialImpl.h similarity index 98% rename from panda/src/express/pipelineCyclerTrivialImpl.h rename to panda/src/pipeline/pipelineCyclerTrivialImpl.h index 44e4cd1b59..42c91dff0f 100644 --- a/panda/src/express/pipelineCyclerTrivialImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrivialImpl.h @@ -47,7 +47,7 @@ class Pipeline; // object, so that the inherited struct's data is likely // to be placed by the compiler at the "this" pointer. //////////////////////////////////////////////////////////////////// -struct EXPCL_PANDAEXPRESS PipelineCyclerTrivialImpl { +struct EXPCL_PANDA PipelineCyclerTrivialImpl { public: INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); private: diff --git a/panda/src/express/pipelineCyclerTrueImpl.I b/panda/src/pipeline/pipelineCyclerTrueImpl.I similarity index 100% rename from panda/src/express/pipelineCyclerTrueImpl.I rename to panda/src/pipeline/pipelineCyclerTrueImpl.I diff --git a/panda/src/express/pipelineCyclerTrueImpl.cxx b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx similarity index 99% rename from panda/src/express/pipelineCyclerTrueImpl.cxx rename to panda/src/pipeline/pipelineCyclerTrueImpl.cxx index d92a5098d0..ed2c9bd479 100644 --- a/panda/src/express/pipelineCyclerTrueImpl.cxx +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.cxx @@ -20,7 +20,7 @@ #ifdef THREADED_PIPELINE -#include "config_express.h" +#include "config_pipeline.h" #include "pipeline.h" //////////////////////////////////////////////////////////////////// diff --git a/panda/src/express/pipelineCyclerTrueImpl.h b/panda/src/pipeline/pipelineCyclerTrueImpl.h similarity index 97% rename from panda/src/express/pipelineCyclerTrueImpl.h rename to panda/src/pipeline/pipelineCyclerTrueImpl.h index c685f66316..dfe60b3174 100644 --- a/panda/src/express/pipelineCyclerTrueImpl.h +++ b/panda/src/pipeline/pipelineCyclerTrueImpl.h @@ -47,7 +47,7 @@ class Pipeline; // mainly to be consistent with // PipelineCyclerTrivialImpl. //////////////////////////////////////////////////////////////////// -struct EXPCL_PANDAEXPRESS PipelineCyclerTrueImpl : public PipelineCyclerLinks { +struct EXPCL_PANDA PipelineCyclerTrueImpl : public PipelineCyclerLinks { private: PipelineCyclerTrueImpl(); public: diff --git a/panda/src/pipeline/pipeline_composite1.cxx b/panda/src/pipeline/pipeline_composite1.cxx new file mode 100644 index 0000000000..bf079737fd --- /dev/null +++ b/panda/src/pipeline/pipeline_composite1.cxx @@ -0,0 +1,19 @@ +#include "atomicAdjust.cxx" +#include "atomicAdjustDummyImpl.cxx" +#include "atomicAdjustNsprImpl.cxx" +#include "atomicAdjustPosixImpl.cxx" +#include "atomicAdjustWin32Impl.cxx" +#include "conditionVar.cxx" +#include "conditionVarDebug.cxx" +#include "conditionVarDirect.cxx" +#include "conditionVarDummyImpl.cxx" +#include "conditionVarNsprImpl.cxx" +#include "conditionVarPosixImpl.cxx" +#include "conditionVarWin32Impl.cxx" +#include "config_pipeline.cxx" +#include "cycleData.cxx" +#include "cycleDataReader.cxx" +#include "cycleDataStageReader.cxx" +#include "cycleDataStageWriter.cxx" +#include "cycleDataWriter.cxx" +#include "cyclerHolder.cxx" diff --git a/panda/src/pipeline/pipeline_composite2.cxx b/panda/src/pipeline/pipeline_composite2.cxx new file mode 100644 index 0000000000..c71a0046c5 --- /dev/null +++ b/panda/src/pipeline/pipeline_composite2.cxx @@ -0,0 +1,18 @@ +#include "externalThread.cxx" +#include "mainThread.cxx" +#include "mutexDebug.cxx" +#include "mutexDirect.cxx" +#include "mutexHolder.cxx" +#include "pipeline.cxx" +#include "pipelineCycler.cxx" +#include "pipelineCyclerDummyImpl.cxx" +#include "pipelineCyclerTrivialImpl.cxx" +#include "pipelineCyclerTrueImpl.cxx" +#include "pmutex.cxx" +#include "reMutex.cxx" +#include "reMutexHolder.cxx" +#include "thread.cxx" +#include "threadDummyImpl.cxx" +#include "threadNsprImpl.cxx" +#include "threadPosixImpl.cxx" +#include "threadWin32Impl.cxx" diff --git a/panda/src/express/pmutex.I b/panda/src/pipeline/pmutex.I similarity index 100% rename from panda/src/express/pmutex.I rename to panda/src/pipeline/pmutex.I diff --git a/panda/src/express/pmutex.cxx b/panda/src/pipeline/pmutex.cxx similarity index 100% rename from panda/src/express/pmutex.cxx rename to panda/src/pipeline/pmutex.cxx diff --git a/panda/src/express/pmutex.h b/panda/src/pipeline/pmutex.h similarity index 95% rename from panda/src/express/pmutex.h rename to panda/src/pipeline/pmutex.h index 1b19af8a3d..c113a7f935 100644 --- a/panda/src/express/pmutex.h +++ b/panda/src/pipeline/pmutex.h @@ -43,9 +43,9 @@ // definition of DEBUG_THREADS. //////////////////////////////////////////////////////////////////// #ifdef DEBUG_THREADS -class EXPCL_PANDAEXPRESS Mutex : public MutexDebug +class EXPCL_PANDA Mutex : public MutexDebug #else -class EXPCL_PANDAEXPRESS Mutex : public MutexDirect +class EXPCL_PANDA Mutex : public MutexDirect #endif // DEBUG_THREADS { public: diff --git a/panda/src/express/reMutex.I b/panda/src/pipeline/reMutex.I similarity index 100% rename from panda/src/express/reMutex.I rename to panda/src/pipeline/reMutex.I diff --git a/panda/src/express/reMutex.cxx b/panda/src/pipeline/reMutex.cxx similarity index 100% rename from panda/src/express/reMutex.cxx rename to panda/src/pipeline/reMutex.cxx diff --git a/panda/src/express/reMutex.h b/panda/src/pipeline/reMutex.h similarity index 93% rename from panda/src/express/reMutex.h rename to panda/src/pipeline/reMutex.h index 6323115229..e01c14fcc0 100644 --- a/panda/src/express/reMutex.h +++ b/panda/src/pipeline/reMutex.h @@ -35,9 +35,9 @@ // definition of DEBUG_THREADS. //////////////////////////////////////////////////////////////////// #ifdef DEBUG_THREADS -class EXPCL_PANDAEXPRESS ReMutex : public MutexDebug +class EXPCL_PANDA ReMutex : public MutexDebug #else -class EXPCL_PANDAEXPRESS ReMutex : public ReMutexDirect +class EXPCL_PANDA ReMutex : public ReMutexDirect #endif // DEBUG_THREADS { public: diff --git a/panda/src/express/reMutexDirect.I b/panda/src/pipeline/reMutexDirect.I similarity index 100% rename from panda/src/express/reMutexDirect.I rename to panda/src/pipeline/reMutexDirect.I diff --git a/panda/src/express/reMutexDirect.cxx b/panda/src/pipeline/reMutexDirect.cxx similarity index 100% rename from panda/src/express/reMutexDirect.cxx rename to panda/src/pipeline/reMutexDirect.cxx diff --git a/panda/src/express/reMutexDirect.h b/panda/src/pipeline/reMutexDirect.h old mode 100755 new mode 100644 similarity index 97% rename from panda/src/express/reMutexDirect.h rename to panda/src/pipeline/reMutexDirect.h index d65e9a2a06..23f9ccbfce --- a/panda/src/express/reMutexDirect.h +++ b/panda/src/pipeline/reMutexDirect.h @@ -31,7 +31,7 @@ class Thread; // direct calls to the underlying implementation layer. // It doesn't perform any debugging operations. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ReMutexDirect { +class EXPCL_PANDA ReMutexDirect { protected: INLINE ReMutexDirect(); INLINE ~ReMutexDirect(); diff --git a/panda/src/express/reMutexHolder.I b/panda/src/pipeline/reMutexHolder.I similarity index 100% rename from panda/src/express/reMutexHolder.I rename to panda/src/pipeline/reMutexHolder.I diff --git a/panda/src/express/reMutexHolder.cxx b/panda/src/pipeline/reMutexHolder.cxx similarity index 100% rename from panda/src/express/reMutexHolder.cxx rename to panda/src/pipeline/reMutexHolder.cxx diff --git a/panda/src/express/reMutexHolder.h b/panda/src/pipeline/reMutexHolder.h similarity index 97% rename from panda/src/express/reMutexHolder.h rename to panda/src/pipeline/reMutexHolder.h index 786e078fc1..da488908e4 100644 --- a/panda/src/express/reMutexHolder.h +++ b/panda/src/pipeline/reMutexHolder.h @@ -26,7 +26,7 @@ // Class : ReMutexHolder // Description : Similar to MutexHolder, but for a reentrant mutex. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ReMutexHolder { +class EXPCL_PANDA ReMutexHolder { public: INLINE ReMutexHolder(const ReMutex &mutex); INLINE ReMutexHolder(ReMutex *&mutex); diff --git a/panda/src/express/test_diners.cxx b/panda/src/pipeline/test_diners.cxx similarity index 100% rename from panda/src/express/test_diners.cxx rename to panda/src/pipeline/test_diners.cxx diff --git a/panda/src/express/test_threaddata.cxx b/panda/src/pipeline/test_threaddata.cxx similarity index 100% rename from panda/src/express/test_threaddata.cxx rename to panda/src/pipeline/test_threaddata.cxx diff --git a/panda/src/express/thread.I b/panda/src/pipeline/thread.I similarity index 100% rename from panda/src/express/thread.I rename to panda/src/pipeline/thread.I diff --git a/panda/src/express/thread.cxx b/panda/src/pipeline/thread.cxx similarity index 100% rename from panda/src/express/thread.cxx rename to panda/src/pipeline/thread.cxx diff --git a/panda/src/express/thread.h b/panda/src/pipeline/thread.h similarity index 98% rename from panda/src/express/thread.h rename to panda/src/pipeline/thread.h index 8c02ce57a2..4fabbfca27 100644 --- a/panda/src/express/thread.h +++ b/panda/src/pipeline/thread.h @@ -42,7 +42,7 @@ class MutexDebug; // will automatically be destructed if no other pointers // are referencing it. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS Thread : public TypedReferenceCount { +class EXPCL_PANDA Thread : public TypedReferenceCount { protected: INLINE Thread(const string &name, const string &sync_name); diff --git a/panda/src/express/threadDummyImpl.I b/panda/src/pipeline/threadDummyImpl.I similarity index 100% rename from panda/src/express/threadDummyImpl.I rename to panda/src/pipeline/threadDummyImpl.I diff --git a/panda/src/express/threadDummyImpl.cxx b/panda/src/pipeline/threadDummyImpl.cxx similarity index 100% rename from panda/src/express/threadDummyImpl.cxx rename to panda/src/pipeline/threadDummyImpl.cxx diff --git a/panda/src/express/threadDummyImpl.h b/panda/src/pipeline/threadDummyImpl.h similarity index 97% rename from panda/src/express/threadDummyImpl.h rename to panda/src/pipeline/threadDummyImpl.h index 31ee8fe351..b2c0019739 100644 --- a/panda/src/express/threadDummyImpl.h +++ b/panda/src/pipeline/threadDummyImpl.h @@ -41,7 +41,7 @@ class Thread; // applications. This simply fails whenever you try to // start a thread. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ThreadDummyImpl { +class EXPCL_PANDA ThreadDummyImpl { public: INLINE ThreadDummyImpl(Thread *parent_obj); INLINE ~ThreadDummyImpl(); diff --git a/panda/src/express/threadImpl.h b/panda/src/pipeline/threadImpl.h similarity index 100% rename from panda/src/express/threadImpl.h rename to panda/src/pipeline/threadImpl.h diff --git a/panda/src/express/threadNsprImpl.I b/panda/src/pipeline/threadNsprImpl.I similarity index 100% rename from panda/src/express/threadNsprImpl.I rename to panda/src/pipeline/threadNsprImpl.I diff --git a/panda/src/express/threadNsprImpl.cxx b/panda/src/pipeline/threadNsprImpl.cxx similarity index 99% rename from panda/src/express/threadNsprImpl.cxx rename to panda/src/pipeline/threadNsprImpl.cxx index 73f23c3444..73e5b48a2e 100644 --- a/panda/src/express/threadNsprImpl.cxx +++ b/panda/src/pipeline/threadNsprImpl.cxx @@ -22,7 +22,7 @@ #ifdef THREAD_NSPR_IMPL #include "pointerTo.h" -#include "config_express.h" +#include "config_pipeline.h" PRUintn ThreadNsprImpl::_pt_ptr_index = 0; bool ThreadNsprImpl::_got_pt_ptr_index = false; diff --git a/panda/src/express/threadNsprImpl.h b/panda/src/pipeline/threadNsprImpl.h similarity index 97% rename from panda/src/express/threadNsprImpl.h rename to panda/src/pipeline/threadNsprImpl.h index 9bc2c31b7f..bd353d0e6d 100644 --- a/panda/src/express/threadNsprImpl.h +++ b/panda/src/pipeline/threadNsprImpl.h @@ -37,7 +37,7 @@ class Thread; // Class : ThreadNsprImpl // Description : Uses NSPR to implement a thread. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ThreadNsprImpl { +class EXPCL_PANDA ThreadNsprImpl { public: INLINE ThreadNsprImpl(Thread *parent_obj); ~ThreadNsprImpl(); diff --git a/panda/src/express/threadPosixImpl.I b/panda/src/pipeline/threadPosixImpl.I similarity index 100% rename from panda/src/express/threadPosixImpl.I rename to panda/src/pipeline/threadPosixImpl.I diff --git a/panda/src/express/threadPosixImpl.cxx b/panda/src/pipeline/threadPosixImpl.cxx similarity index 85% rename from panda/src/express/threadPosixImpl.cxx rename to panda/src/pipeline/threadPosixImpl.cxx index c10941589f..483bc38a3b 100644 --- a/panda/src/express/threadPosixImpl.cxx +++ b/panda/src/pipeline/threadPosixImpl.cxx @@ -22,7 +22,7 @@ #ifdef THREAD_POSIX_IMPL #include "pointerTo.h" -#include "config_express.h" +#include "config_pipeline.h" #include @@ -84,42 +84,50 @@ start(ThreadPriority priority, bool global, bool joinable) { _detached = true; } - struct sched_param param; - int current_policy; - int result = pthread_attr_getschedpolicy(&attr, ¤t_policy); + // Ensure the thread has "system" scope, which should ensure it can + // run in parallel with other threads. + int result = pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); if (result != 0) { thread_cat.warning() - << "Unable to query scheduling policy.\n"; + << "Unable to set system scope.\n"; + } - } else { - int result = 0; - switch (priority) { - case TP_low: - param.sched_priority = sched_get_priority_min(current_policy); - result = pthread_attr_setschedparam(&attr, ¶m); - break; - - case TP_high: - case TP_urgent: - param.sched_priority = sched_get_priority_max(current_policy); - result = pthread_attr_setschedparam(&attr, ¶m); - break; - - case TP_normal: - default: - break; - } + struct sched_param param; + int current_policy = SCHED_OTHER; + result = pthread_attr_setschedpolicy(&attr, SCHED_OTHER); + if (result != 0) { + thread_cat.warning() + << "Unable to set scheduling policy.\n"; - if (result != 0) { - thread_cat.warning() - << "Unable to specify thread priority.\n"; - } + } + + result = 0; + switch (priority) { + case TP_low: + param.sched_priority = sched_get_priority_min(current_policy); + result = pthread_attr_setschedparam(&attr, ¶m); + break; + + case TP_high: + case TP_urgent: + param.sched_priority = sched_get_priority_max(current_policy); + result = pthread_attr_setschedparam(&attr, ¶m); + break; + + case TP_normal: + default: + break; + } + + if (result != 0) { + thread_cat.warning() + << "Unable to specify thread priority.\n"; } // Increment the parent object's reference count first. The thread // will eventually decrement it when it terminates. _parent_obj->ref(); - result = pthread_create(&_thread, &attr, &root_func, (void *)this); + result = pthread_create(&_thread, &attr, &root_func, (void *)this); pthread_attr_destroy(&attr); diff --git a/panda/src/express/threadPosixImpl.h b/panda/src/pipeline/threadPosixImpl.h similarity index 97% rename from panda/src/express/threadPosixImpl.h rename to panda/src/pipeline/threadPosixImpl.h index 2759a176ec..77261e3514 100644 --- a/panda/src/express/threadPosixImpl.h +++ b/panda/src/pipeline/threadPosixImpl.h @@ -36,7 +36,7 @@ class Thread; // Class : ThreadPosixImpl // Description : Uses Posix threads to implement a thread. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ThreadPosixImpl { +class EXPCL_PANDA ThreadPosixImpl { public: INLINE ThreadPosixImpl(Thread *parent_obj); ~ThreadPosixImpl(); diff --git a/panda/src/express/threadPriority.h b/panda/src/pipeline/threadPriority.h similarity index 100% rename from panda/src/express/threadPriority.h rename to panda/src/pipeline/threadPriority.h diff --git a/panda/src/express/threadWin32Impl.I b/panda/src/pipeline/threadWin32Impl.I similarity index 100% rename from panda/src/express/threadWin32Impl.I rename to panda/src/pipeline/threadWin32Impl.I diff --git a/panda/src/express/threadWin32Impl.cxx b/panda/src/pipeline/threadWin32Impl.cxx similarity index 99% rename from panda/src/express/threadWin32Impl.cxx rename to panda/src/pipeline/threadWin32Impl.cxx index f74894254e..3774ae8376 100644 --- a/panda/src/express/threadWin32Impl.cxx +++ b/panda/src/pipeline/threadWin32Impl.cxx @@ -22,7 +22,7 @@ #ifdef THREAD_WIN32_IMPL #include "pointerTo.h" -#include "config_express.h" +#include "config_pipeline.h" DWORD ThreadWin32Impl::_pt_ptr_index = 0; bool ThreadWin32Impl::_got_pt_ptr_index = false; diff --git a/panda/src/express/threadWin32Impl.h b/panda/src/pipeline/threadWin32Impl.h similarity index 97% rename from panda/src/express/threadWin32Impl.h rename to panda/src/pipeline/threadWin32Impl.h index 2823a21a98..7a0a308252 100644 --- a/panda/src/express/threadWin32Impl.h +++ b/panda/src/pipeline/threadWin32Impl.h @@ -37,7 +37,7 @@ class Thread; // Class : ThreadWin32Impl // Description : Uses native Windows calls to implement a thread. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ThreadWin32Impl { +class EXPCL_PANDA ThreadWin32Impl { public: INLINE ThreadWin32Impl(Thread *parent_obj); ~ThreadWin32Impl(); diff --git a/panda/src/pstatclient/Sources.pp b/panda/src/pstatclient/Sources.pp index 8d00aaf8e2..e8cbe33562 100644 --- a/panda/src/pstatclient/Sources.pp +++ b/panda/src/pstatclient/Sources.pp @@ -3,7 +3,7 @@ #begin lib_target #define LOCAL_LIBS \ - net linmath putil express + net putil express #define TARGET pstatclient diff --git a/panda/src/pstatclient/pStatClient.cxx b/panda/src/pstatclient/pStatClient.cxx index b80ad757ae..d5022f9c9a 100644 --- a/panda/src/pstatclient/pStatClient.cxx +++ b/panda/src/pstatclient/pStatClient.cxx @@ -30,11 +30,13 @@ #include "config_pstats.h" #include "pStatProperties.h" #include "thread.h" +#include "mutexDebug.h" PStatCollector PStatClient::_total_size_pcollector("Memory usage"); PStatCollector PStatClient::_cpp_size_pcollector("Memory usage:C++"); PStatCollector PStatClient::_interpreter_size_pcollector("Memory usage:Interpreter"); PStatCollector PStatClient::_pstats_pcollector("*:PStats"); +PStatCollector PStatClient::_mutex_wait_pcollector("Wait:Mutex block"); PStatClient *PStatClient::_global_pstats = NULL; @@ -71,6 +73,11 @@ PStatClient() : // The main thread is always at index 0. make_thread(Thread::get_main_thread()); + + // Assign the hacky callback pointers into MutexDebug. +#ifdef DEBUG_THREADS + MutexDebug::set_pstats_callbacks(&mutex_wait_start, &mutex_wait_stop); +#endif // DEBUG_THREADS } //////////////////////////////////////////////////////////////////// @@ -411,6 +418,25 @@ make_collector_with_name(int parent_index, const string &name) { return PStatCollector(this, new_index); } +//////////////////////////////////////////////////////////////////// +// Function: PStatClient::do_get_current_thread +// Access: Private +// Description: Similar to get_current_thread, but does not grab the +// lock. +//////////////////////////////////////////////////////////////////// +PStatThread PStatClient:: +do_get_current_thread() const { + Thread *thread = Thread::get_current_thread(); + int thread_index = thread->get_pstats_index(); + if (thread_index != -1) { + return PStatThread((PStatClient *)this, thread_index); + } + + // This is the first time we have encountered this current Thread. + // Make a new PStatThread object for it. + return ((PStatClient *)this)->do_make_thread(thread); +} + //////////////////////////////////////////////////////////////////// // Function: PStatClient::make_thread // Access: Private @@ -421,7 +447,16 @@ make_collector_with_name(int parent_index, const string &name) { PStatThread PStatClient:: make_thread(Thread *thread) { ReMutexHolder holder(_lock); + return do_make_thread(thread); +} +//////////////////////////////////////////////////////////////////// +// Function: PStatClient::do_make_thread +// Access: Private +// Description: As above, but assumes the lock is already held. +//////////////////////////////////////////////////////////////////// +PStatThread PStatClient:: +do_make_thread(Thread *thread) { int thread_index = thread->get_pstats_index(); if (thread_index != -1) { return PStatThread((PStatClient *)this, thread_index); @@ -731,6 +766,95 @@ get_level(int collector_index, int thread_index) const { get_collector_def(collector_index)->_factor; } +//////////////////////////////////////////////////////////////////// +// Function: PStatClient::mutex_wait_start +// Access: Private, Static +// Description: A special-purpose callback function we use to hack a +// PStatTimer into the MutexDebug system. This will be +// called (when DEBUG_THREADS is set) when the thread +// goes to sleep on a mutex. +//////////////////////////////////////////////////////////////////// +void PStatClient:: +mutex_wait_start() { +#ifdef DEBUG_THREADS + // We replicate the code from start(), except we do not grab the + // mutex. We can't, because that would be recursive (this function + // is called from deep with Mutex::lock()). However, we don't need + // to, because this code is only called when the global mutex is + // held (the global mutex only exists in the case of MUTEX_DEBUG). + PStatClient *self = get_global_pstats(); + int collector_index = _mutex_wait_pcollector._index; + int thread_index = self->do_get_current_thread()._index; + +#ifdef _DEBUG + nassertv(collector_index >= 0 && collector_index < (int)self->_collectors.size()); + nassertv(thread_index >= 0 && thread_index < (int)self->_threads.size()); +#endif + + bool is_connected = self->has_impl() && self->_impl->client_is_connected(); + if (is_connected && + self->_collectors[collector_index].is_active() && + self->_threads[thread_index]._is_active) { + if (self->_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) { + // This collector wasn't already started in this thread; record + // a new data point. + self->_threads[thread_index]._frame_data.add_start(collector_index, + self->_impl->get_clock().get_real_time()); + } + self->_collectors[collector_index]._per_thread[thread_index]._nested_count++; + } +#endif // DEBUG_THREADS +} + +//////////////////////////////////////////////////////////////////// +// Function: PStatClient::mutex_wait_stop +// Access: Private, Static +// Description: A special-purpose callback function we use to hack a +// PStatTimer into the MutexDebug system. This will be +// called (when DEBUG_THREADS is set) when the thread +// wakes up after blocking on a mutex. +//////////////////////////////////////////////////////////////////// +void PStatClient:: +mutex_wait_stop() { +#ifdef DEBUG_THREADS + // As above, we replicate the code from stop(), except we do not + // grab the mutex. + + PStatClient *self = get_global_pstats(); + int collector_index = _mutex_wait_pcollector._index; + int thread_index = self->do_get_current_thread()._index; + +#ifdef _DEBUG + nassertv(collector_index >= 0 && collector_index < (int)self->_collectors.size()); + nassertv(thread_index >= 0 && thread_index < (int)self->_threads.size()); +#endif + + bool is_connected = self->has_impl() && self->_impl->client_is_connected(); + if (is_connected && + self->_collectors[collector_index].is_active() && + self->_threads[thread_index]._is_active) { + if (self->_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) { + if (pstats_cat.is_debug()) { + pstats_cat.debug() + << "Collector " << self->get_collector_fullname(collector_index) + << " was already stopped in thread " << self->get_thread_name(thread_index) + << "!\n"; + } + return; + } + + self->_collectors[collector_index]._per_thread[thread_index]._nested_count--; + if (self->_collectors[collector_index]._per_thread[thread_index]._nested_count == 0) { + // This collector has now been completely stopped; record a new + // data point. + self->_threads[thread_index]._frame_data.add_stop(collector_index, + self->_impl->get_clock().get_real_time()); + } + } + +#endif // DEBUG_THREADS +} + //////////////////////////////////////////////////////////////////// // Function: PStatClient::Collector::make_def // Access: Private diff --git a/panda/src/pstatclient/pStatClient.h b/panda/src/pstatclient/pStatClient.h index 3c2037b583..b59b983fb2 100644 --- a/panda/src/pstatclient/pStatClient.h +++ b/panda/src/pstatclient/pStatClient.h @@ -26,7 +26,6 @@ #include "pStatCollectorDef.h" #include "reMutex.h" #include "reMutexHolder.h" -#include "luse.h" #include "pmap.h" #include "thread.h" #include "weakPointerTo.h" @@ -108,7 +107,9 @@ private: PStatCollector make_collector_with_relname(int parent_index, string relname); PStatCollector make_collector_with_name(int parent_index, const string &name); + PStatThread do_get_current_thread() const; PStatThread make_thread(Thread *thread); + PStatThread do_make_thread(Thread *thread); bool is_active(int collector_index, int thread_index) const; bool is_started(int collector_index, int thread_index) const; @@ -123,6 +124,9 @@ private: void add_level(int collector_index, int thread_index, float increment); float get_level(int collector_index, int thread_index) const; + static void mutex_wait_start(); + static void mutex_wait_stop(); + private: // This mutex protects everything in this class. ReMutex _lock; @@ -196,6 +200,7 @@ private: static PStatCollector _cpp_size_pcollector; static PStatCollector _interpreter_size_pcollector; static PStatCollector _pstats_pcollector; + static PStatCollector _mutex_wait_pcollector; static PStatClient *_global_pstats; diff --git a/panda/src/pstatclient/pStatClientImpl.h b/panda/src/pstatclient/pStatClientImpl.h index 1d83a87e8c..5fcde07cdc 100644 --- a/panda/src/pstatclient/pStatClientImpl.h +++ b/panda/src/pstatclient/pStatClientImpl.h @@ -31,7 +31,6 @@ #include "netAddress.h" #include "clockObject.h" -#include "luse.h" #include "pmap.h" class PStatClient; diff --git a/panda/src/pstatclient/pStatCollector.h b/panda/src/pstatclient/pStatCollector.h index 7db9ba5125..120d0f7718 100644 --- a/panda/src/pstatclient/pStatCollector.h +++ b/panda/src/pstatclient/pStatCollector.h @@ -24,8 +24,6 @@ #include "pStatThread.h" #include "pStatClient.h" -#include "luse.h" - //////////////////////////////////////////////////////////////////// // Class : PStatCollector // Description : A lightweight class that represents a single element diff --git a/panda/src/pstatclient/pStatCollectorDef.cxx b/panda/src/pstatclient/pStatCollectorDef.cxx index 0a01bc62e2..902ab92394 100644 --- a/panda/src/pstatclient/pStatCollectorDef.cxx +++ b/panda/src/pstatclient/pStatCollectorDef.cxx @@ -31,7 +31,9 @@ PStatCollectorDef:: PStatCollectorDef() { _index = 0; _parent_index = 0; - _suggested_color.set(0.0, 0.0, 0.0); + _suggested_color.r = 0.0; + _suggested_color.g = 0.0; + _suggested_color.b = 0.0; _sort = -1; _suggested_scale = 0.0; _factor = 1.0; @@ -50,7 +52,9 @@ PStatCollectorDef(int index, const string &name) : _name(name) { _parent_index = 0; - _suggested_color.set(0.0, 0.0, 0.0); + _suggested_color.r = 0.0; + _suggested_color.g = 0.0; + _suggested_color.b = 0.0; _sort = -1; _suggested_scale = 0.0; _factor = 1.0; @@ -87,7 +91,9 @@ write_datagram(Datagram &destination) const { destination.add_int16(_index); destination.add_string(_name); destination.add_int16(_parent_index); - _suggested_color.write_datagram(destination); + destination.add_float32(_suggested_color.r); + destination.add_float32(_suggested_color.g); + destination.add_float32(_suggested_color.b); destination.add_int16(_sort); destination.add_string(_level_units); destination.add_float32(_suggested_scale); @@ -104,7 +110,9 @@ read_datagram(DatagramIterator &source, PStatClientVersion *) { _index = source.get_int16(); _name = source.get_string(); _parent_index = source.get_int16(); - _suggested_color.read_datagram(source); + _suggested_color.r = source.get_float32(); + _suggested_color.g = source.get_float32(); + _suggested_color.b = source.get_float32(); _sort = source.get_int16(); _level_units = source.get_string(); _suggested_scale = source.get_float32(); diff --git a/panda/src/pstatclient/pStatCollectorDef.h b/panda/src/pstatclient/pStatCollectorDef.h index dd033c50d4..4064d57833 100644 --- a/panda/src/pstatclient/pStatCollectorDef.h +++ b/panda/src/pstatclient/pStatCollectorDef.h @@ -21,8 +21,6 @@ #include "pandabase.h" -#include "luse.h" - class Datagram; class DatagramIterator; class PStatClient; @@ -42,10 +40,14 @@ public: void write_datagram(Datagram &destination) const; void read_datagram(DatagramIterator &source, PStatClientVersion *version); + struct ColorDef { + float r, g, b; + }; + int _index; string _name; int _parent_index; - RGBColorf _suggested_color; + ColorDef _suggested_color; int _sort; string _level_units; float _suggested_scale; diff --git a/panda/src/pstatclient/pStatProperties.cxx b/panda/src/pstatclient/pStatProperties.cxx index 88422dd665..1193ee648b 100644 --- a/panda/src/pstatclient/pStatProperties.cxx +++ b/panda/src/pstatclient/pStatProperties.cxx @@ -88,9 +88,7 @@ get_current_pstat_minor_version() { // //////////////////////////////////////////////////////////////////// -struct ColorDef { - float r, g, b; -}; +typedef PStatCollectorDef::ColorDef ColorDef; struct TimeCollectorProperties { bool is_active; @@ -110,6 +108,7 @@ struct LevelCollectorProperties { static TimeCollectorProperties time_properties[] = { { 1, "Wait", { 0.6, 0.6, 0.6 } }, + { 0, "Wait:Mutex block", { 1.0, 0.0, 0.0 } }, { 1, "App", { 0.0, 0.8, 0.4 }, 1.0 / 30.0 }, { 1, "App:Collisions", { 1.0, 0.5, 0.0 } }, { 1, "App:Collisions:Reset", { 0.0, 0.0, 0.5 } }, @@ -226,7 +225,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d if (!def->_active_explicitly_set) { def->_is_active = tp.is_active; } - def->_suggested_color.set(tp.color.r, tp.color.g, tp.color.b); + def->_suggested_color = tp.color; if (tp.suggested_scale != 0.0) { def->_suggested_scale = tp.suggested_scale; } @@ -243,7 +242,7 @@ initialize_collector_def_from_table(const string &fullname, PStatCollectorDef *d if (!def->_active_explicitly_set) { def->_is_active = lp.is_active; } - def->_suggested_color.set(lp.color.r, lp.color.g, lp.color.b); + def->_suggested_color = lp.color; if (lp.suggested_scale != 0.0) { def->_suggested_scale = lp.suggested_scale; } @@ -330,9 +329,9 @@ initialize_collector_def(const PStatClient *client, PStatCollectorDef *def) { } if (pstats_color.has_value()) { - def->_suggested_color[0] = pstats_color[0]; - def->_suggested_color[1] = pstats_color[1]; - def->_suggested_color[2] = pstats_color[2]; + def->_suggested_color.r = pstats_color[0]; + def->_suggested_color.g = pstats_color[1]; + def->_suggested_color.b = pstats_color[2]; } } diff --git a/panda/src/pstatclient/test_client.cxx b/panda/src/pstatclient/test_client.cxx index 3368f081ad..2eafaf2402 100644 --- a/panda/src/pstatclient/test_client.cxx +++ b/panda/src/pstatclient/test_client.cxx @@ -20,7 +20,6 @@ #include "pStatClient.h" #include "pStatCollector.h" -#include "luse.h" #include "queuedConnectionManager.h" #include "queuedConnectionReader.h" #include "connectionWriter.h" diff --git a/panda/src/putil/Sources.pp b/panda/src/putil/Sources.pp index cf50d46232..cc0b77b9fb 100644 --- a/panda/src/putil/Sources.pp +++ b/panda/src/putil/Sources.pp @@ -1,6 +1,6 @@ #define OTHER_LIBS interrogatedb:c dconfig:c dtoolconfig:m \ dtoolutil:c dtoolbase:c dtool:m prc:c -#define LOCAL_LIBS express pandabase +#define LOCAL_LIBS pipeline express pandabase #define USE_PACKAGES zlib #begin lib_target @@ -20,6 +20,7 @@ buttonHandle.I \ buttonHandle.h buttonRegistry.I buttonRegistry.h \ cachedTypedWritableReferenceCount.h cachedTypedWritableReferenceCount.I \ + clockObject.h clockObject.I \ collideMask.h \ portalMask.h \ compareTo.I compareTo.h \ @@ -68,6 +69,7 @@ bitMask.cxx \ buttonHandle.cxx buttonRegistry.cxx \ cachedTypedWritableReferenceCount.cxx \ + clockObject.cxx \ config_util.cxx configurable.cxx \ datagramInputFile.cxx datagramOutputFile.cxx \ factoryBase.cxx \ @@ -104,6 +106,7 @@ buttonHandle.I buttonHandle.h buttonRegistry.I \ buttonRegistry.h \ cachedTypedWritableReferenceCount.h cachedTypedWritableReferenceCount.I \ + clockObject.h clockObject.I \ collideMask.h portalMask.h \ compareTo.I compareTo.h \ config_util.h configurable.h factory.I factory.h \ diff --git a/panda/src/express/clockObject.I b/panda/src/putil/clockObject.I similarity index 100% rename from panda/src/express/clockObject.I rename to panda/src/putil/clockObject.I diff --git a/panda/src/express/clockObject.cxx b/panda/src/putil/clockObject.cxx similarity index 98% rename from panda/src/express/clockObject.cxx rename to panda/src/putil/clockObject.cxx index 502bb83678..3ca96be819 100644 --- a/panda/src/express/clockObject.cxx +++ b/panda/src/putil/clockObject.cxx @@ -16,9 +16,8 @@ // //////////////////////////////////////////////////////////////////// - #include "clockObject.h" -#include "config_express.h" +#include "config_util.h" #include "configVariableEnum.h" #include "thread.h" @@ -32,7 +31,7 @@ TypeHandle ClockObject::_type_handle; //////////////////////////////////////////////////////////////////// ClockObject:: ClockObject() { - _true_clock = TrueClock::get_ptr(); + _true_clock = TrueClock::get_global_ptr(); // Each clock except for the application global clock is created in // M_normal mode. The application global clock is later reset to @@ -63,7 +62,7 @@ void ClockObject:: set_real_time(double time) { #ifdef NOTIFY_DEBUG if (this == _global_clock) { - express_cat.warning() + util_cat.warning() << "Adjusting global clock's real time by " << time - get_real_time() << " seconds.\n"; } @@ -85,7 +84,7 @@ set_frame_time(double time) { nassertv(Thread::get_current_pipeline_stage() == 0); #ifdef NOTIFY_DEBUG if (this == _global_clock && _mode != M_slave) { - express_cat.warning() + util_cat.warning() << "Adjusting global clock's frame time by " << time - get_frame_time() << " seconds.\n"; } @@ -107,7 +106,7 @@ set_frame_count(int frame_count) { nassertv(Thread::get_current_pipeline_stage() == 0); #ifdef NOTIFY_DEBUG if (this == _global_clock && _mode != M_slave) { - express_cat.warning() + util_cat.warning() << "Adjusting global clock's frame count by " << frame_count - get_frame_count() << " frames.\n"; } @@ -325,7 +324,7 @@ operator >> (istream &in, ClockObject::Mode &mode) { } else if (word == "slave") { mode = ClockObject::M_slave; } else { - express_cat.error() + util_cat.error() << "Invalid ClockObject::Mode: " << word << "\n"; mode = ClockObject::M_normal; } diff --git a/panda/src/express/clockObject.h b/panda/src/putil/clockObject.h similarity index 96% rename from panda/src/express/clockObject.h rename to panda/src/putil/clockObject.h index b9b73cb00a..fd34864b63 100644 --- a/panda/src/express/clockObject.h +++ b/panda/src/putil/clockObject.h @@ -30,7 +30,7 @@ #include "pipelineCycler.h" #include "thread.h" -class EXPCL_PANDAEXPRESS TimeVal { +class EXPCL_PANDA TimeVal { PUBLISHED: INLINE TimeVal(); INLINE ulong get_sec() const; @@ -63,7 +63,7 @@ PUBLISHED: // up to tick every frame so that its get_frame_time() // will return the time for the current frame. //////////////////////////////////////////////////////////////////// -class EXPCL_PANDAEXPRESS ClockObject { +class EXPCL_PANDA ClockObject { PUBLISHED: enum Mode { M_normal, @@ -131,7 +131,7 @@ private: Ticks _ticks; // This is the data that needs to be cycled each frame. - class EXPCL_PANDAEXPRESS CData : public CycleData { + class EXPCL_PANDA CData : public CycleData { public: CData(); INLINE CData(const CData ©); @@ -165,9 +165,9 @@ private: static TypeHandle _type_handle; }; -EXPCL_PANDAEXPRESS ostream & +EXPCL_PANDA ostream & operator << (ostream &out, ClockObject::Mode mode); -EXPCL_PANDAEXPRESS istream & +EXPCL_PANDA istream & operator >> (istream &in, ClockObject::Mode &mode); #include "clockObject.I" diff --git a/panda/src/putil/config_util.cxx b/panda/src/putil/config_util.cxx index 8a3ed0b273..7ab6a9b3d9 100644 --- a/panda/src/putil/config_util.cxx +++ b/panda/src/putil/config_util.cxx @@ -80,6 +80,7 @@ ConfigureFn(config_util) { BitArray::init_type(); BitMask32::init_type(); CachedTypedWritableReferenceCount::init_type(); + ClockObject::init_type(); Configurable::init_type(); Datagram::init_type(); FactoryParam::init_type(); @@ -127,3 +128,17 @@ ConfigVariableSearchPath & get_sound_path() { return sound_path; } + +ConfigVariableDouble clock_frame_rate +("clock-frame-rate", 1.0); +ConfigVariableDouble clock_degrade_factor +("clock-degrade-factor", 1.0); +ConfigVariableDouble max_dt +("max-dt", -1.0); + +ConfigVariableDouble sleep_precision +("sleep-precision", 0.01, + PRC_DESC("This is the accuracy within which we can expect select() to " + "return precisely. That is, if we use select() to request a " + "timeout of 1.0 seconds, we can expect to actually sleep for " + "somewhere between 1.0 and 1.0 + sleep-precision seconds.")); diff --git a/panda/src/putil/config_util.h b/panda/src/putil/config_util.h index cb6ace487f..d9d131cdca 100644 --- a/panda/src/putil/config_util.h +++ b/panda/src/putil/config_util.h @@ -54,4 +54,9 @@ EXPCL_PANDA ConfigVariableSearchPath &get_texture_path(); EXPCL_PANDA ConfigVariableSearchPath &get_sound_path(); END_PUBLISH +extern ConfigVariableDouble clock_frame_rate; +extern ConfigVariableDouble clock_degrade_factor; +extern ConfigVariableDouble max_dt; +extern ConfigVariableDouble sleep_precision; + #endif /* __CONFIG_UTIL_H__ */ diff --git a/panda/src/putil/putil_composite1.cxx b/panda/src/putil/putil_composite1.cxx index a433aad4f4..bf11ad29b2 100644 --- a/panda/src/putil/putil_composite1.cxx +++ b/panda/src/putil/putil_composite1.cxx @@ -9,6 +9,7 @@ #include "buttonHandle.cxx" #include "buttonRegistry.cxx" #include "cachedTypedWritableReferenceCount.cxx" +#include "clockObject.cxx" #include "config_util.cxx" #include "configurable.cxx" #include "datagramInputFile.cxx"