Make ownership of SocketMultiplexer explicit

This commit is contained in:
Povilas Kanapickas 2019-08-17 16:17:49 +03:00
parent e31ebc1b22
commit 8dd6bc2c55
4 changed files with 8 additions and 8 deletions

View File

@ -200,7 +200,7 @@ App::initApp(int argc, const char** argv)
void void
App::initIpcClient() App::initIpcClient()
{ {
m_ipcClient = new IpcClient(m_events, m_socketMultiplexer); m_ipcClient = new IpcClient(m_events, m_socketMultiplexer.get());
m_ipcClient->connect(); m_ipcClient->connect();
m_events->adoptHandler( m_events->adoptHandler(

View File

@ -23,7 +23,9 @@
#include "base/String.h" #include "base/String.h"
#include "base/Log.h" #include "base/Log.h"
#include "base/EventQueue.h" #include "base/EventQueue.h"
#include "net/SocketMultiplexer.h"
#include "common/common.h" #include "common/common.h"
#include <memory>
#if SYSAPI_WIN32 #if SYSAPI_WIN32
#include "barrier/win32/AppUtilWindows.h" #include "barrier/win32/AppUtilWindows.h"
@ -95,8 +97,8 @@ public:
virtual IEventQueue* getEvents() const { return m_events; } virtual IEventQueue* getEvents() const { return m_events; }
void setSocketMultiplexer(SocketMultiplexer* sm) { m_socketMultiplexer = sm; } void setSocketMultiplexer(std::unique_ptr<SocketMultiplexer>&& sm) { m_socketMultiplexer = std::move(sm); }
SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer; } SocketMultiplexer* getSocketMultiplexer() const { return m_socketMultiplexer.get(); }
void setEvents(EventQueue& events) { m_events = &events; } void setEvents(EventQueue& events) { m_events = &events; }
@ -119,7 +121,7 @@ private:
CreateTaskBarReceiverFunc m_createTaskBarReceiver; CreateTaskBarReceiverFunc m_createTaskBarReceiver;
ARCH_APP_UTIL m_appUtil; ARCH_APP_UTIL m_appUtil;
IpcClient* m_ipcClient; IpcClient* m_ipcClient;
SocketMultiplexer* m_socketMultiplexer; std::unique_ptr<SocketMultiplexer> m_socketMultiplexer;
}; };
class MinimalApp : public App { class MinimalApp : public App {

View File

@ -443,8 +443,7 @@ 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

@ -713,8 +713,7 @@ 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