15 #include <boost/function.hpp>
16 #include <boost/noncopyable.hpp>
17 #include <tbb/tick_count.h>
23 #include <unordered_map>
26 #include <condition_variable>
34 #ifdef DtObjectDebugger_Enable
38 typedef std::shared_ptr<ThreadInfo>
Ptr;
39 typedef std::list<Ptr>
List;
58 #ifdef DtObjectDebugger_Enable
63 typedef std::shared_ptr<CallbackInterface>
Ptr;
72 virtual std::string label()
const;
75 virtual void run() = 0;
78 virtual void cancel();
81 virtual bool valid()
const;
87 const std::string& label,
94 virtual std::string label()
const;
97 static void cleanup();
100 virtual void setWarnTime(
double seconds);
101 virtual void setWarnTime(
double seconds, std::ostream& output);
104 virtual void setWarnQueueMinInterval(
double seconds);
107 virtual void setWarnLabelMinInterval(
double seconds);
110 virtual void printInfo(std::ostream&,
size_t width=0)
const;
113 virtual size_t totalNumberOfCallbacks()
const;
116 virtual unsigned size()
const;
119 virtual size_t numExecuting()
const;
122 virtual unsigned maxTasks()
const;
126 virtual void setMaxTasks(
unsigned tasks,
bool wait=
true);
131 void shutdown(
bool wait =
true);
134 virtual void clear(
bool wait =
true);
137 virtual void add_back(
const Callback&,
const std::string& label =
"");
140 virtual void add_front(
const Callback&,
const std::string& label =
"");
168 virtual bool runOne(
bool block=
false,
ThreadInfo* info=0);
173 virtual void runAll(
bool useThisThread=
false);
188 #ifdef DtObjectDebugger_Enable
192 typedef std::list<Record>
List;
203 typedef std::unique_lock<Mutex>
Lock;
221 typedef std::multimap<double, std::ostream*, std::greater<double> >
StreamMap;
232 void sweepWarnMap(tbb::tick_count now);
std::string name
Definition: vrfCallbackQueue.h:44
Definition: vrfCallbackQueue.h:235
Definition: vrfCallbackQueue.h:33
virtual void cancel() override
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:246
std::mutex myWarnThrottleMutex
Definition: vrfCallbackQueue.h:224
Record::List myCallbacks
Definition: vrfCallbackQueue.h:210
ThreadInfo::List myThreads
Definition: vrfCallbackQueue.h:209
std::thread thread
Definition: vrfCallbackQueue.h:45
virtual void cancel() override
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:262
DtVrfCallbackQueue::CallbackInterface & myCallback
Definition: vrfCallbackQueue.h:265
voidpf void uLong size
Definition: ioapi.h:39
const tbb::tick_count timeAdded
Definition: vrfCallbackQueue.h:195
Condition myCondition
Definition: vrfCallbackQueue.h:206
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:31
Default on in debug, off in release.
Definition: objectCounter.h:27
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:31
virtual void run()=0
Run callback.
std::unique_lock< Mutex > Lock
Definition: vrfCallbackQueue.h:203
std::atomic< size_t > myNumExecuting
Definition: vrfCallbackQueue.h:215
This is a class which maintains a list of string command names and the callback functions that are to...
Definition: consoleCommandManager.h:55
Definition: vrfCallbackQueue.h:252
Callback record.
Definition: vrfCallbackQueue.h:187
boost::function< void()> Callback
Definition: vrfCallbackQueue.h:54
std::string myLabel
Definition: vrfCallbackQueue.h:219
std::list< Ptr > List
Definition: vrfCallbackQueue.h:39
std::shared_ptr< CallbackInterface > Ptr
Definition: vrfCallbackQueue.h:63
virtual std::string label() const override
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:244
virtual void cancel()
Will be called if the callback will not be run before it's discarded.
API for writing callbacks.
Definition: vrfCallbackQueue.h:57
RefWrapper(DtVrfCallbackQueue::CallbackInterface &i)
Definition: vrfCallbackQueue.h:256
tbb::tick_count myLastQueueWarnTime
Definition: vrfCallbackQueue.h:227
std::unordered_map< std::string, tbb::tick_count > myLastWarnByLabel
Definition: vrfCallbackQueue.h:228
size_t myTotalNumCallbacks
Definition: vrfCallbackQueue.h:213
Condition myDoneCondition
Definition: vrfCallbackQueue.h:207
double myWarnLabelMinInterval
Definition: vrfCallbackQueue.h:226
bool myShutdownFlag
Definition: vrfCallbackQueue.h:212
std::list< Record > List
Definition: vrfCallbackQueue.h:192
std::multimap< double, std::ostream *, std::greater< double > > StreamMap
Definition: vrfCallbackQueue.h:221
virtual void run() override
Run callback.
Definition: vrfCallbackQueue.h:245
DtVrfCallbackQueue::CallbackInterface * myCallback
Definition: vrfCallbackQueue.h:249
virtual ~Wrapper() override
Definition: vrfCallbackQueue.h:243
std::shared_ptr< ThreadInfo > Ptr
Definition: vrfCallbackQueue.h:38
const CallbackInterface::Ptr callback
Definition: vrfCallbackQueue.h:194
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
virtual std::string label() const override
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:260
std::condition_variable Condition
Definition: vrfCallbackQueue.h:202
bool quitFlag
Definition: vrfCallbackQueue.h:43
virtual void run() override
Run callback.
Definition: vrfCallbackQueue.h:261
Wrapper(DtVrfCallbackQueue::CallbackInterface *i)
Definition: vrfCallbackQueue.h:239
virtual std::string label() const
Name of callback, used only for logging and debugging.
StreamMap myWarnTimes
Definition: vrfCallbackQueue.h:222
std::mutex Mutex
Definition: vrfCallbackQueue.h:201
tbb::tick_count myLastWarnMapSweep
Definition: vrfCallbackQueue.h:229
DtConsoleCommandManager * myConsoleManager
Definition: vrfCallbackQueue.h:217
double myWarnQueueMinInterval
Definition: vrfCallbackQueue.h:225
Mutex myMutex
Definition: vrfCallbackQueue.h:205