summaryrefslogtreecommitdiff
path: root/indra/llcommon/lleventdispatcher.h
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2022-12-20 09:53:58 -0500
committerNat Goodspeed <nat@lindenlab.com>2023-07-13 12:34:31 -0400
commitcc3d21cceac7d6c1b2fc9297330fa819855f6e5b (patch)
tree785ba0cde81b2719e003800cd4dca6096e8724a5 /indra/llcommon/lleventdispatcher.h
parent8855a82f512286bce6bd131d87dcafd303f2a5f6 (diff)
DRTVWR-558: Tweak LLEventDispatcher.
Instead of std::map<std::string, boost::shared_ptr>, use std::unique_ptr as the mapped_type, using emplace() to store new entries. This more correctly captures the desired semantics: we have no intention of passing around the pointers in the map, we just want the map to delete them on destruction. Use std::function instead of boost::function. (cherry picked from commit 7ba53ef82db5683756e296225f0c8b838420a26e)
Diffstat (limited to 'indra/llcommon/lleventdispatcher.h')
-rw-r--r--indra/llcommon/lleventdispatcher.h21
1 files changed, 7 insertions, 14 deletions
diff --git a/indra/llcommon/lleventdispatcher.h b/indra/llcommon/lleventdispatcher.h
index 6d1df86fea..cf88dced12 100644
--- a/indra/llcommon/lleventdispatcher.h
+++ b/indra/llcommon/lleventdispatcher.h
@@ -56,9 +56,6 @@ static const auto nil_(nil);
static const auto& nil(nil_);
#endif
-#include <string>
-#include <boost/shared_ptr.hpp>
-#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/function_types/is_nonmember_callable_builtin.hpp>
@@ -73,6 +70,9 @@ static const auto& nil(nil_);
#include <boost/mpl/end.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/deref.hpp>
+#include <functional> // std::function
+#include <memory> // std::unique_ptr
+#include <string>
#include <typeinfo>
#include "llevents.h"
#include "llsdutil.h"
@@ -96,7 +96,7 @@ public:
/// Accept any C++ callable with the right signature, typically a
/// boost::bind() expression
- typedef boost::function<void(const LLSD&)> Callable;
+ typedef std::function<void(const LLSD&)> Callable;
/**
* Register a @a callable by @a name. The passed @a callable accepts a
@@ -293,14 +293,7 @@ private:
virtual void call(const std::string& desc, const LLSD& event) const = 0;
virtual LLSD addMetadata(LLSD) const = 0;
};
- // Tried using boost::ptr_map<std::string, DispatchEntry>, but ptr_map<>
- // wants its value type to be "clonable," even just to dereference an
- // iterator. I don't want to clone entries -- if I have to copy an entry
- // around, I want it to continue pointing to the same DispatchEntry
- // subclass object. However, I definitely want DispatchMap to destroy
- // DispatchEntry if no references are outstanding at the time an entry is
- // removed. This looks like a job for boost::shared_ptr.
- typedef std::map<std::string, boost::shared_ptr<DispatchEntry> > DispatchMap;
+ typedef std::map<std::string, std::unique_ptr<DispatchEntry> > DispatchMap;
public:
/// We want the flexibility to redefine what data we store per name,
@@ -363,10 +356,10 @@ private:
struct invoker;
// deliver LLSD arguments one at a time
- typedef boost::function<LLSD()> args_source;
+ typedef std::function<LLSD()> args_source;
// obtain args from an args_source to build param list and call target
// function
- typedef boost::function<void(const args_source&)> invoker_function;
+ typedef std::function<void(const args_source&)> invoker_function;
template <typename Function>
invoker_function make_invoker(Function f);