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.
22 using nod::connection;
23 using nod::scoped_connection;
27 /// A small utility to use with signals2::slot_type::track_foreign when the
28 /// parent object is not handled by a shared_ptr, or to track the lifetime of an
29 /// object. Using Trackable to track lifetimes is less thread-safe than tracking
30 /// their parents directly with a shared_ptr as recommended by signals2, but it
31 /// makes it easier for transitioning old code. (Essentially because Trackable
32 /// will not prevent the deletion of the parent by a concurrent thread.)
35 Trackable() : p_(std::make_shared<int>(0)) {}
36 Trackable(Trackable const &) : Trackable() {}
37 Trackable(Trackable &&) : Trackable() {}
38 Trackable & operator=(Trackable const &) { return *this; }
39 Trackable & operator=(Trackable &&) { return *this; }
40 // This weak pointer lets you know if the parent object has been destroyed
41 std::weak_ptr<void> p() const { return p_; }
43 std::shared_ptr<void> const p_;
46 } // namespace support