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

Jürgen Spitzmüller spitz at lyx.org
Sun Dec 20 09:21:27 UTC 2020


Am Samstag, dem 19.12.2020 um 21:22 +0100 schrieb Yuriy Skalko:
> 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

I'm now getting

In file included from Server.cpp:43:
Server.h:196:14: error: field ‘pipename_’ has incomplete type
‘std::string’ {aka ‘std::__cxx11::basic_string<char>’}
  196 |  std::string pipename_;
      |              ^~~~~~~~~
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/memory:74,
                 from Server.h:17,
                 from Server.cpp:43:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of
‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
   74 |     class basic_string;
      |           ^~~~~~~~~~~~
In file included from Server.cpp:43:
Server.h:244:14: error: field ‘clients_’ has incomplete type
‘std::string [10]’ {aka ‘std::__cxx11::basic_string<char> [10]’}
  244 |  std::string clients_[MAX_CLIENTS];
      |              ^~~~~~~~
In file included from /usr/include/c++/10/iosfwd:39,
                 from /usr/include/c++/10/memory:74,
                 from Server.h:17,
                 from Server.cpp:43:
/usr/include/c++/10/bits/stringfwd.h:74:11: note: declaration of
‘std::string’ {aka ‘class std::__cxx11::basic_string<char>’}
   74 |     class basic_string;
      |           ^~~~~~~~~~~~

Jürgen

> ---
>  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20201220/7a489ebf/attachment-0001.asc>


More information about the lyx-devel mailing list