15 #include <boost/function.hpp>
16 #include <boost/shared_ptr.hpp>
17 #include <boost/noncopyable.hpp>
19 #include <tbb/mutex.h>
20 #include <tbb/tbb_thread.h>
21 #include <tbb/compat/condition_variable>
22 #include <tbb/spin_mutex.h>
23 #include <tbb/atomic.h>
35 #ifdef DtObjectDebugger_Enable
39 typedef boost::shared_ptr<ThreadInfo>
Ptr;
40 typedef std::list<Ptr>
List;
59 #ifdef DtObjectDebugger_Enable
64 typedef boost::shared_ptr<CallbackInterface>
Ptr;
73 virtual std::string label()
const;
76 virtual void run() = 0;
79 virtual void cancel();
82 virtual bool valid()
const;
88 const std::string& label,
95 virtual std::string label()
const;
98 static void cleanup();
101 virtual void setWarnTime(
double seconds);
102 virtual void setWarnTime(
double seconds, std::ostream& output);
105 virtual void printInfo(std::ostream&,
size_t width=0)
const;
108 virtual size_t totalNumberOfCallbacks()
const;
111 virtual unsigned size()
const;
114 virtual size_t numExecuting()
const;
117 virtual unsigned maxTasks()
const;
121 virtual void setMaxTasks(
unsigned tasks,
bool wait=
true);
126 void shutdown(
bool wait =
true);
129 virtual void clear(
bool wait =
true);
132 virtual void add_back(
const Callback&,
const std::string& label =
"");
135 virtual void add_front(
const Callback&,
const std::string& label =
"");
161 virtual bool runOne(
bool block=
false,
ThreadInfo* info=0);
166 virtual void runAll(
bool useThisThread=
false);
181 #ifdef DtObjectDebugger_Enable
185 typedef std::list<Record>
List;
196 typedef tbb::interface5::unique_lock<Mutex>
Lock;
214 typedef std::multimap<double, std::ostream*, std::greater<double> >
StreamMap;
std::string name
Definition: vrfCallbackQueue.h:45
Definition: vrfCallbackQueue.h:218
Definition: vrfCallbackQueue.h:34
~Wrapper()
Definition: vrfCallbackQueue.h:223
void run()
Run callback.
Definition: vrfCallbackQueue.h:225
tbb::mutex Mutex
Definition: vrfCallbackQueue.h:194
Record::List myCallbacks
Definition: vrfCallbackQueue.h:203
ThreadInfo::List myThreads
Definition: vrfCallbackQueue.h:202
DtVrfCallbackQueue::CallbackInterface & myCallback
Definition: vrfCallbackQueue.h:242
voidpf void uLong size
Definition: ioapi.h:39
const tbb::tick_count timeAdded
Definition: vrfCallbackQueue.h:188
Condition myCondition
Definition: vrfCallbackQueue.h:199
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:265
Default on in debug, off in release.
Definition: objectCounter.h:31
tbb::atomic< size_t > myNumExecuting
Definition: vrfCallbackQueue.h:208
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
virtual void run()=0
Run callback.
This is a class which maintains a list of string command names and the callback functions that are to...
Definition: consoleCommandManager.h:56
Definition: vrfCallbackQueue.h:232
Callback record.
Definition: vrfCallbackQueue.h:180
boost::function< void()> Callback
Definition: vrfCallbackQueue.h:55
std::string myLabel
Definition: vrfCallbackQueue.h:212
std::list< Ptr > List
Definition: vrfCallbackQueue.h:40
tbb::interface5::condition_variable Condition
Definition: vrfCallbackQueue.h:195
virtual void cancel()
Will be called if the callback will not be run before it's discarded.
API for writing callbacks.
Definition: vrfCallbackQueue.h:58
void run()
Run callback.
Definition: vrfCallbackQueue.h:238
RefWrapper(DtVrfCallbackQueue::CallbackInterface &i)
Definition: vrfCallbackQueue.h:236
void cancel()
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:226
size_t myTotalNumCallbacks
Definition: vrfCallbackQueue.h:206
Condition myDoneCondition
Definition: vrfCallbackQueue.h:200
bool myShutdownFlag
Definition: vrfCallbackQueue.h:205
std::list< Record > List
Definition: vrfCallbackQueue.h:185
std::multimap< double, std::ostream *, std::greater< double > > StreamMap
Definition: vrfCallbackQueue.h:214
DtVrfCallbackQueue::CallbackInterface * myCallback
Definition: vrfCallbackQueue.h:229
tbb::tbb_thread thread
Definition: vrfCallbackQueue.h:46
std::string label() const
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:224
const CallbackInterface::Ptr callback
Definition: vrfCallbackQueue.h:187
std::string label() const
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:237
void cancel()
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:239
#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
bool quitFlag
Definition: vrfCallbackQueue.h:44
tbb::interface5::unique_lock< Mutex > Lock
Definition: vrfCallbackQueue.h:196
boost::shared_ptr< ThreadInfo > Ptr
Definition: vrfCallbackQueue.h:39
Wrapper(DtVrfCallbackQueue::CallbackInterface *i)
Definition: vrfCallbackQueue.h:222
virtual std::string label() const
Name of callback, used only for logging and debugging.
StreamMap myWarnTimes
Definition: vrfCallbackQueue.h:215
DtConsoleCommandManager * myConsoleManager
Definition: vrfCallbackQueue.h:210
Mutex myMutex
Definition: vrfCallbackQueue.h:198
boost::shared_ptr< CallbackInterface > Ptr
Definition: vrfCallbackQueue.h:64