5 #ifndef CVMFS_UTIL_ASYNC_H_
6 #define CVMFS_UTIL_ASYNC_H_
8 #ifdef CVMFS_NAMESPACE_GUARD
9 namespace CVMFS_NAMESPACE_GUARD {
20 template<
typename ParamT>
24 virtual void operator()(
const ParamT &value)
const = 0;
31 virtual void operator()()
const = 0;
44 template<
typename ParamT>
47 typedef void (*CallbackFunction)(
const ParamT &value);
49 explicit Callback(CallbackFunction
function) : function_(function) { }
50 void operator()(
const ParamT &value)
const { function_(value); }
59 typedef void (*CallbackFunction)();
61 explicit Callback(CallbackFunction
function) : function_(function) { }
83 template<
typename ParamT,
class DelegateT>
86 typedef void (DelegateT::*CallbackMethod)(
const ParamT &value);
89 : delegate_(delegate), method_(method) { }
91 void operator()(
const ParamT &value)
const { (delegate_->*method_)(value); }
98 template<
class DelegateT>
101 typedef void (DelegateT::*CallbackMethod)();
104 : delegate_(delegate), method_(method) { }
127 template<
typename ParamT,
class DelegateT,
typename ClosureDataT>
130 typedef void (DelegateT::*CallbackMethod)(
const ParamT &value,
131 const ClosureDataT closure_data);
134 BoundClosure(CallbackMethod method, DelegateT *delegate, ClosureDataT data)
135 : delegate_(delegate), method_(method), closure_data_(data) { }
138 (delegate_->*method_)(value, closure_data_);
147 template<
class DelegateT,
typename ClosureDataT>
150 typedef void (DelegateT::*CallbackMethod)(
const ClosureDataT closure_data);
153 BoundClosure(CallbackMethod method, DelegateT *delegate, ClosureDataT data)
154 : delegate_(delegate), method_(method), closure_data_(data) { }
156 void operator()()
const { (delegate_->*method_)(closure_data_); }
182 template<
class ParamT>
196 template<
class DelegateT,
typename ClosureDataT>
201 const ClosureDataT &closure_data) {
203 method, delegate, closure_data);
212 template<
class DelegateT>
215 DelegateT *delegate) {
238 template<
class DelegateT>
239 void ThreadProxy(DelegateT *delegate,
void (DelegateT::*method)()) {
240 (*delegate.*method)();
244 #ifdef CVMFS_NAMESPACE_GUARD
248 #endif // CVMFS_UTIL_ASYNC_H_
CallbackFunction function_
const ClosureDataT closure_data_
void operator()(const ParamT &value) const
static CallbackTN * MakeCallback(typename BoundCallback< ParamT, DelegateT >::CallbackMethod method, DelegateT *delegate)
Callback(CallbackFunction function)
const ClosureDataT closure_data_
void operator()(const ParamT &value) const
BoundCallback(CallbackMethod method, DelegateT *delegate)
Callback(CallbackFunction function)
void operator()(const ParamT &value) const
BoundCallback(CallbackMethod method, DelegateT *delegate)
BoundClosure(CallbackMethod method, DelegateT *delegate, ClosureDataT data)
static CallbackTN * MakeCallback(typename Callback< ParamT >::CallbackFunction function)
void ThreadProxy(DelegateT *delegate, void(DelegateT::*method)())
CallbackBase< ParamT > CallbackTN
CallbackFunction function_
BoundClosure(CallbackMethod method, DelegateT *delegate, ClosureDataT data)
static CallbackTN * MakeClosure(typename BoundClosure< ParamT, DelegateT, ClosureDataT >::CallbackMethod method, DelegateT *delegate, const ClosureDataT &closure_data)