# include <bits/c++0x_warning.h>
#else
-#include <functional>
-#include <list>
-#include <memory>
-#include <tuple>
-#include <type_traits>
-
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/arithmetic/add.hpp>
-#include <boost/preprocessor/repetition/repeat.hpp>
-
#include <dpl/event/event_support.h>
#include <dpl/event/thread_event_dispatcher.h>
#include <dpl/event/main_event_dispatcher.h>
+#include <dpl/fast_delegate.h>
#include <dpl/generic_event.h>
#include <dpl/foreach.h>
#include <dpl/recursive_mutex.h>
#include <dpl/log/log.h>
#include <dpl/assert.h>
#include <dpl/apply.h>
+#include <tuple>
+#include <list>
+#include <memory>
/*
* - Created ICDelegate can be passed freely to other threads.
template <typename ... ArgTypesList>
friend class DPL::Event::ICDelegate;
};
-
-
-template<size_t N>
-struct PlaceholdersBindHelper;
-
-#define DPL_PLACEHOLDERS_LIST_(z, n, t) ,BOOST_PP_CAT(std::placeholders::_, \
- BOOST_PP_ADD(n, 1))
-#define DPL_PLACEHOLDERS_(count) BOOST_PP_REPEAT(count, \
- DPL_PLACEHOLDERS_LIST_, \
- count)
-#define DPL_PLACEHOLDERS_BIND_HELPER_(count) \
-template<> \
-struct PlaceholdersBindHelper<count> \
-{ \
- template<typename Functor, typename ...Args> \
- static auto bind(Functor&& f, Args&&... args) \
- -> decltype(std::bind(std::forward<Functor>(f), \
- std::forward<Args>(args)... \
- DPL_PLACEHOLDERS_(count))) { \
- return std::bind(std::forward<Functor>(f), \
- std::forward<Args>(args)... \
- DPL_PLACEHOLDERS_(count)); \
- } \
-}
-
-DPL_PLACEHOLDERS_BIND_HELPER_(0);
-DPL_PLACEHOLDERS_BIND_HELPER_(1);
-DPL_PLACEHOLDERS_BIND_HELPER_(2);
-DPL_PLACEHOLDERS_BIND_HELPER_(3);
-DPL_PLACEHOLDERS_BIND_HELPER_(4);
-DPL_PLACEHOLDERS_BIND_HELPER_(5);
-DPL_PLACEHOLDERS_BIND_HELPER_(6);
-DPL_PLACEHOLDERS_BIND_HELPER_(7);
-DPL_PLACEHOLDERS_BIND_HELPER_(8);
-
-template<typename Functor>
-struct BindHelper;
-
-template<typename R, typename Type, typename ...Args>
-struct BindHelper<R(Type::*)(Args...)>
-{
- typedef std::function<R(Args...)> ResultType;
-
- template<typename Functor>
- static ResultType bind(Functor&& f, Type* type) {
- return PlaceholdersBindHelper<sizeof...(Args)>::
- bind(std::forward<Functor>(f), type);
- }
-};
-
-template<typename R, typename ...Args>
-struct BindHelper<R(Args...)>
-{
- typedef std::function<R(Args...)> ResultType;
-
- template<typename Functor>
- static ResultType bind(Functor&& f) {
- return PlaceholdersBindHelper<sizeof...(Args)>::
- bind(std::forward<Functor>(f));
- }
-};
-
-template<typename Functor, typename ...Args>
-typename BindHelper<typename std::decay<Functor>::type>::ResultType
-bind(Functor&& f, Args&&... args)
-{
- return BindHelper<typename std::decay<Functor>::type>::
- bind(std::forward<Functor>(f), std::forward<Args>(args)...);
-}
} //ICDPrivate
// Better makeDelegate then DPL::MakeDelegate
template<typename ThisType, typename ... ArgTypesList>
-std::function<void (ArgTypesList ...)>
+FastDelegate<void (ArgTypesList ...)>
makeDelegate(ThisType* This,
void (ThisType::*Func)(ArgTypesList ...))
{
- return ICDPrivate::bind(Func, This);
+ return FastDelegate<void (ArgTypesList ...)>(This, Func);
}
// ICDelegate class represents delegate that can be called from
ICDelegate()
{}
ICDelegate(ICDPrivate::ICDelegateSupportInterface* base,
- std::function<void (ArgTypesList ...)> outerDelegate,
+ DPL::FastDelegate<void (ArgTypesList ...)> outerDelegate,
ICD::Reuse reuse)
{
ICDSharedData* hlp = new ICDSharedData(base, outerDelegate, reuse);
std::tuple<ArgTypesList ...> args;
};
- typedef std::function<void (const PrivateEvent&)>
+ typedef DPL::FastDelegate<void (const PrivateEvent&)>
ICDSharedDataDelegateType;
class ICDSharedData : private DPL::Event::EventSupport<PrivateEvent>,
public std::enable_shared_from_this<ICDSharedData>,
public:
ICDSharedData(
ICDPrivate::ICDelegateSupportInterface *base,
- std::function<void (ArgTypesList ...)> outerDelegate,
+ DPL::FastDelegate<void (ArgTypesList ...)> outerDelegate,
ICD::Reuse reuse) :
m_base(base),
m_outerDelegate(outerDelegate),
friend class std::shared_ptr<ICDSharedData>;
ICDSharedDataDelegateType m_subDelegate;
ICDPrivate::ICDelegateSupportInterface* m_base;
- std::function<void (ArgTypesList ...)> m_outerDelegate;
+ DPL::FastDelegate<void (ArgTypesList ...)> m_outerDelegate;
ICD::Reuse m_reuse;
void delegateForwarder(const PrivateEvent& event)
std::static_pointer_cast<ICDSharedDataBase>(event.helper));
ICDPrivate::ICDSharedDataBase::ScopedLock lock(ptr);
- Assert(m_outerDelegate);
+ Assert(!m_outerDelegate.empty());
if (ptr->isDisabled()) {
LogPedantic("ICDSharedData has been disabled - call is ignored");
} else {