From: Yuriy Skalko Date: Wed, 16 Dec 2020 10:07:42 +0000 (+0200) Subject: Move Trackable class to Server.h X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d9e455b61ac7ce8340433754121e565697fd58d1;p=features.git Move Trackable class to Server.h --- diff --git a/src/Server.cpp b/src/Server.cpp index 8d9e0c61db..6549228536 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -55,7 +55,6 @@ #include "support/lassert.h" #include "support/lstrings.h" #include "support/os.h" -#include "support/signals.h" #include diff --git a/src/Server.h b/src/Server.h index b277284ace..2f26b8aef7 100644 --- a/src/Server.h +++ b/src/Server.h @@ -14,8 +14,7 @@ #ifndef SERVER_H #define SERVER_H -#include "support/signals.h" - +#include #include #ifdef _WIN32 @@ -30,6 +29,21 @@ namespace lyx { class Server; +/// A small utility to track the lifetime of an object. +class Trackable { +public: + Trackable() : p_(std::make_shared(0)) {} + Trackable(Trackable const &) : Trackable() {} + Trackable(Trackable &&) : Trackable() {} + Trackable & operator=(Trackable const &) { return *this; } + Trackable & operator=(Trackable &&) { return *this; } + // This weak pointer lets you know if the parent object has been destroyed + std::weak_ptr p() const { return p_; } +private: + std::shared_ptr const p_; +}; + + /** This class manages the pipes used for communicating with clients. Usage: Initialize with pipe-filename-base, client class to receive messages, and callback-function that will be called with the messages. @@ -191,7 +205,7 @@ private: bool deferred_loading_; /// Track object's liveness - support::Trackable tracker_; + Trackable tracker_; }; diff --git a/src/support/signals.h b/src/support/signals.h index 4b55663d55..269b20699f 100644 --- a/src/support/signals.h +++ b/src/support/signals.h @@ -14,38 +14,12 @@ #include -#include - namespace lyx { using nod::signal; using nod::connection; using nod::scoped_connection; -namespace support { - -/// A small utility to use with signals2::slot_type::track_foreign when the -/// parent object is not handled by a shared_ptr, or to track the lifetime of an -/// object. Using Trackable to track lifetimes is less thread-safe than tracking -/// their parents directly with a shared_ptr as recommended by signals2, but it -/// makes it easier for transitioning old code. (Essentially because Trackable -/// will not prevent the deletion of the parent by a concurrent thread.) -class Trackable { -public: - Trackable() : p_(std::make_shared(0)) {} - Trackable(Trackable const &) : Trackable() {} - Trackable(Trackable &&) : Trackable() {} - Trackable & operator=(Trackable const &) { return *this; } - Trackable & operator=(Trackable &&) { return *this; } - // This weak pointer lets you know if the parent object has been destroyed - std::weak_ptr p() const { return p_; } -private: - std::shared_ptr const p_; -}; - -} // namespace support - } // namespace lyx - #endif