[LyX/master] Move Trackable class to Server.h

Yuriy Skalko yuriy.skalko at gmail.com
Sat Dec 19 20:22:24 UTC 2020


commit d9e455b61ac7ce8340433754121e565697fd58d1
Author: Yuriy Skalko <yuriy.skalko at gmail.com>
Date:   Wed Dec 16 12:07:42 2020 +0200

    Move Trackable class to Server.h
---
 src/Server.cpp        |    1 -
 src/Server.h          |   20 +++++++++++++++++---
 src/support/signals.h |   26 --------------------------
 3 files changed, 17 insertions(+), 30 deletions(-)

diff --git a/src/Server.cpp b/src/Server.cpp
index 8d9e0c6..6549228 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 <iostream>
 
diff --git a/src/Server.h b/src/Server.h
index b277284..2f26b8a 100644
--- a/src/Server.h
+++ b/src/Server.h
@@ -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_;
 };
 
 
diff --git a/src/support/signals.h b/src/support/signals.h
index 4b55663..269b206 100644
--- a/src/support/signals.h
+++ b/src/support/signals.h
@@ -14,38 +14,12 @@
 
 #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


More information about the lyx-cvs mailing list