]> git.lyx.org Git - features.git/commitdiff
Move Trackable class to Server.h
authorYuriy Skalko <yuriy.skalko@gmail.com>
Wed, 16 Dec 2020 10:07:42 +0000 (12:07 +0200)
committerYuriy Skalko <yuriy.skalko@gmail.com>
Sat, 19 Dec 2020 20:52:57 +0000 (22:52 +0200)
src/Server.cpp
src/Server.h
src/support/signals.h

index 8d9e0c61db1b10f3bda5467cdc97e8ae06ec9d34..6549228536493452e9404e6793881745554e7b3c 100644 (file)
@@ -55,7 +55,6 @@
 #include "support/lassert.h"
 #include "support/lstrings.h"
 #include "support/os.h"
-#include "support/signals.h"
 
 #include <iostream>
 
index b277284ace9b66b099750720903e437aa272972d..2f26b8aef7d1eabe3ef58a46b325000223359772 100644 (file)
@@ -14,8 +14,7 @@
 #ifndef SERVER_H
 #define SERVER_H
 
-#include "support/signals.h"
-
+#include <memory>
 #include <vector>
 
 #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<int>(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<void> p() const { return p_; }
+private:
+       std::shared_ptr<void> 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_;
 };
 
 
index 4b55663d5572363c14c05f438341794def96f292..269b20699f8486dd052747c3d8e0a12ec8ee376b 100644 (file)
 
 #include <nod.hpp>
 
-#include <memory>
-
 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<int>(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<void> p() const { return p_; }
-private:
-       std::shared_ptr<void> const p_;
-};
-
-} // namespace support
-
 } // namespace lyx
 
-
 #endif