Pulled idle callback functions out of rlvviewer2 and moved them into llcallbacklist where they belong. LLCallbackList brought up to current, as well.
This commit is contained in:
@@ -26,78 +26,6 @@
|
||||
#include "llviewerinventory.h"
|
||||
#include "rlvviewer2.h"
|
||||
|
||||
// ============================================================================
|
||||
// From llappearancemgr.cpp
|
||||
|
||||
// Shim class to allow arbitrary boost::bind
|
||||
// expressions to be run as one-time idle callbacks.
|
||||
//
|
||||
// TODO: rework idle function spec to take a boost::function in the first place.
|
||||
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.
|
||||
//
|
||||
// TODO: rework idle function spec to take a boost::function in the first place.
|
||||
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);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// From llinventoryobserver.cpp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user