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>
36 typedef boost::shared_ptr<ThreadInfo>
Ptr;
37 typedef std::list<Ptr>
List;
59 typedef boost::shared_ptr<CallbackInterface>
Ptr;
68 virtual std::string label()
const;
71 virtual void run() = 0;
74 virtual void cancel();
77 virtual bool valid()
const;
83 const std::string& label,
90 virtual std::string label()
const;
93 static void cleanup();
96 virtual void setWarnTime(
double seconds);
97 virtual void setWarnTime(
double seconds, std::ostream& output);
100 virtual void printInfo(std::ostream&,
size_t width=0)
const;
103 virtual size_t totalNumberOfCallbacks()
const;
106 virtual unsigned size()
const;
109 virtual size_t numExecuting()
const;
112 virtual unsigned maxTasks()
const;
116 virtual void setMaxTasks(
unsigned tasks,
bool wait=
true);
121 void shutdown(
bool wait =
true);
124 virtual void clear(
bool wait =
true);
127 virtual void add_back(
const Callback&,
const std::string& label =
"");
130 virtual void add_front(
const Callback&,
const std::string& label =
"");
156 virtual bool runOne(
bool block=
false,
ThreadInfo* info=0);
161 virtual void runAll(
bool useThisThread=
false);
177 typedef std::list<Record>
List;
188 typedef tbb::interface5::unique_lock<Mutex>
Lock;
206 typedef std::multimap<double, std::ostream*, std::greater<double> >
StreamMap;
std::string name
Definition: vrfCallbackQueue.h:42
Definition: vrfCallbackQueue.h:210
Definition: vrfCallbackQueue.h:34
~Wrapper()
Definition: vrfCallbackQueue.h:215
void run()
Run callback.
Definition: vrfCallbackQueue.h:217
tbb::mutex Mutex
Definition: vrfCallbackQueue.h:186
Record::List myCallbacks
Definition: vrfCallbackQueue.h:195
ThreadInfo::List myThreads
Definition: vrfCallbackQueue.h:194
DtVrfCallbackQueue::CallbackInterface & myCallback
Definition: vrfCallbackQueue.h:234
voidpf void uLong size
Definition: ioapi.h:39
const tbb::tick_count timeAdded
Definition: vrfCallbackQueue.h:180
Condition myCondition
Definition: vrfCallbackQueue.h:191
#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:200
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:48
Definition: vrfCallbackQueue.h:224
Callback record.
Definition: vrfCallbackQueue.h:175
boost::function< void()> Callback
Definition: vrfCallbackQueue.h:52
std::string myLabel
Definition: vrfCallbackQueue.h:204
std::list< Ptr > List
Definition: vrfCallbackQueue.h:37
tbb::interface5::condition_variable Condition
Definition: vrfCallbackQueue.h:187
virtual void cancel()
Will be called if the callback will not be run before it's discarded.
API for writing callbacks.
Definition: vrfCallbackQueue.h:55
void run()
Run callback.
Definition: vrfCallbackQueue.h:230
RefWrapper(DtVrfCallbackQueue::CallbackInterface &i)
Definition: vrfCallbackQueue.h:228
void cancel()
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:218
size_t myTotalNumCallbacks
Definition: vrfCallbackQueue.h:198
Condition myDoneCondition
Definition: vrfCallbackQueue.h:192
bool myShutdownFlag
Definition: vrfCallbackQueue.h:197
std::list< Record > List
Definition: vrfCallbackQueue.h:177
std::multimap< double, std::ostream *, std::greater< double > > StreamMap
Definition: vrfCallbackQueue.h:206
DtVrfCallbackQueue::CallbackInterface * myCallback
Definition: vrfCallbackQueue.h:221
tbb::tbb_thread thread
Definition: vrfCallbackQueue.h:43
std::string label() const
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:216
const CallbackInterface::Ptr callback
Definition: vrfCallbackQueue.h:179
std::string label() const
Name of callback, used only for logging and debugging.
Definition: vrfCallbackQueue.h:229
void cancel()
Will be called if the callback will not be run before it's discarded.
Definition: vrfCallbackQueue.h:231
#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:41
tbb::interface5::unique_lock< Mutex > Lock
Definition: vrfCallbackQueue.h:188
boost::shared_ptr< ThreadInfo > Ptr
Definition: vrfCallbackQueue.h:36
Wrapper(DtVrfCallbackQueue::CallbackInterface *i)
Definition: vrfCallbackQueue.h:214
virtual std::string label() const
Name of callback, used only for logging and debugging.
StreamMap myWarnTimes
Definition: vrfCallbackQueue.h:207
DtConsoleCommandManager * myConsoleManager
Definition: vrfCallbackQueue.h:202
Mutex myMutex
Definition: vrfCallbackQueue.h:190
boost::shared_ptr< CallbackInterface > Ptr
Definition: vrfCallbackQueue.h:59