4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Guillaume Munch
9 * Full author contact details are available in file CREDITS.
15 #include <boost/signals2/signal.hpp>
21 namespace signals2 = ::boost::signals2;
25 /// A small utility to use with signals2::slot_type::track_foreign when the
26 /// parent object is not handled by a shared_ptr, or to track the lifetime of an
27 /// object. Using Trackable to track lifetimes is less thread-safe than tracking
28 /// their parents directly with a shared_ptr as recommended by signals2, but it
29 /// makes it easier for transitioning old code. (Essentially because Trackable
30 /// will not prevent the deletion of the parent by a concurrent thread.)
33 Trackable() : p_(std::make_shared<int>(0)) {}
34 Trackable(Trackable const &) : Trackable() {}
35 Trackable(Trackable &&) : Trackable() {}
36 Trackable & operator=(Trackable const &) { return *this; }
37 Trackable & operator=(Trackable &&) { return *this; }
38 // This weak pointer lets you know if the parent object has been destroyed
39 std::weak_ptr<void> p() const { return p_; }
41 std::shared_ptr<void> const p_;
44 } // namespace support