Reapply "refactor: App use Uniqueprt for SocketMultiplexer"

This reverts commit 6f18cf74c5.
This commit is contained in:
Nick Bolton 2025-09-12 15:49:34 +01:00
parent 6f18cf74c5
commit fcdea215be
3 changed files with 8 additions and 8 deletions

View file

@ -11,6 +11,7 @@
#include "base/Log.h" #include "base/Log.h"
#include "common/Common.h" #include "common/Common.h"
#include "deskflow/IApp.h" #include "deskflow/IApp.h"
#include "net/SocketMultiplexer.h"
#if SYSAPI_WIN32 #if SYSAPI_WIN32
#include "deskflow/win32/AppUtilWindows.h" #include "deskflow/win32/AppUtilWindows.h"
@ -18,6 +19,7 @@
#include "deskflow/unix/AppUtilUnix.h" #include "deskflow/unix/AppUtilUnix.h"
#endif #endif
#include <memory>
#include <stdexcept> #include <stdexcept>
namespace deskflow { namespace deskflow {
@ -91,14 +93,14 @@ public:
{ {
m_events = &events; m_events = &events;
} }
void setSocketMultiplexer(SocketMultiplexer *sm) void setSocketMultiplexer(std::unique_ptr<SocketMultiplexer> &&sm)
{ {
m_socketMultiplexer = sm; m_socketMultiplexer = std::move(sm);
} }
SocketMultiplexer *getSocketMultiplexer() const SocketMultiplexer *getSocketMultiplexer() const
{ {
return m_socketMultiplexer; return m_socketMultiplexer.get();
} }
static App &instance() static App &instance()
@ -119,7 +121,7 @@ private:
static App *s_instance; static App *s_instance;
FileLogOutputter *m_fileLog = nullptr; FileLogOutputter *m_fileLog = nullptr;
ARCH_APP_UTIL m_appUtil; ARCH_APP_UTIL m_appUtil;
SocketMultiplexer *m_socketMultiplexer = nullptr; std::unique_ptr<SocketMultiplexer> m_socketMultiplexer;
}; };
#if WINAPI_MSWINDOWS #if WINAPI_MSWINDOWS

View file

@ -372,8 +372,7 @@ int ClientApp::mainLoop()
{ {
// create socket multiplexer. this must happen after daemonization // create socket multiplexer. this must happen after daemonization
// on unix because threads evaporate across a fork(). // on unix because threads evaporate across a fork().
SocketMultiplexer multiplexer; setSocketMultiplexer(std::make_unique<SocketMultiplexer>());
setSocketMultiplexer(&multiplexer);
// start client, etc // start client, etc
appUtil().startNode(); appUtil().startNode();

View file

@ -574,8 +574,7 @@ int ServerApp::mainLoop()
{ {
// create socket multiplexer. this must happen after daemonization // create socket multiplexer. this must happen after daemonization
// on unix because threads evaporate across a fork(). // on unix because threads evaporate across a fork().
SocketMultiplexer multiplexer; setSocketMultiplexer(std::make_unique<SocketMultiplexer>());
setSocketMultiplexer(&multiplexer);
// if configuration has no screens then add this system // if configuration has no screens then add this system
// as the default // as the default