summaryrefslogtreecommitdiff
path: root/indra/newview/llcallbacklist.cpp
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2010-12-20 17:11:34 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2010-12-20 17:11:34 -0500
commit4bd6edc6b037195012583467a3e5e754f6a5af77 (patch)
tree6713363bb6c5af098f5eef1c255efbb5baa88b84 /indra/newview/llcallbacklist.cpp
parent6a0e8fc13ec246f69e5718ee91a30117ae703c2a (diff)
SH-682 FIX, SH-594 FIX - removed mFMP wrapper, added thread checking. Moved onIdle functions to llcallbacklist.
Diffstat (limited to 'indra/newview/llcallbacklist.cpp')
-rwxr-xr-x[-rw-r--r--]indra/newview/llcallbacklist.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/indra/newview/llcallbacklist.cpp b/indra/newview/llcallbacklist.cpp
index a54c77b4a0..357a6582d1 100644..100755
--- a/indra/newview/llcallbacklist.cpp
+++ b/indra/newview/llcallbacklist.cpp
@@ -115,6 +115,71 @@ void LLCallbackList::callFunctions()
}
}
+// Shim class to allow arbitrary boost::bind
+// expressions to be run as one-time idle callbacks.
+class OnIdleCallbackOneTime
+{
+public:
+ OnIdleCallbackOneTime(nullary_func_t callable):
+ mCallable(callable)
+ {
+ }
+ static void onIdle(void *data)
+ {
+ gIdleCallbacks.deleteFunction(onIdle, data);
+ OnIdleCallbackOneTime* self = reinterpret_cast<OnIdleCallbackOneTime*>(data);
+ self->call();
+ delete self;
+ }
+ void call()
+ {
+ mCallable();
+ }
+private:
+ nullary_func_t mCallable;
+};
+
+void doOnIdleOneTime(nullary_func_t callable)
+{
+ OnIdleCallbackOneTime* cb_functor = new OnIdleCallbackOneTime(callable);
+ gIdleCallbacks.addFunction(&OnIdleCallbackOneTime::onIdle,cb_functor);
+}
+
+// Shim class to allow generic boost functions to be run as
+// recurring idle callbacks. Callable should return true when done,
+// false to continue getting called.
+class OnIdleCallbackRepeating
+{
+public:
+ OnIdleCallbackRepeating(bool_func_t callable):
+ mCallable(callable)
+ {
+ }
+ // Will keep getting called until the callable returns true.
+ static void onIdle(void *data)
+ {
+ OnIdleCallbackRepeating* self = reinterpret_cast<OnIdleCallbackRepeating*>(data);
+ bool done = self->call();
+ if (done)
+ {
+ gIdleCallbacks.deleteFunction(onIdle, data);
+ delete self;
+ }
+ }
+ bool call()
+ {
+ return mCallable();
+ }
+private:
+ bool_func_t mCallable;
+};
+
+void doOnIdleRepeating(bool_func_t callable)
+{
+ OnIdleCallbackRepeating* cb_functor = new OnIdleCallbackRepeating(callable);
+ gIdleCallbacks.addFunction(&OnIdleCallbackRepeating::onIdle,cb_functor);
+}
+
#ifdef _DEBUG
void test1(void *data)