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
App::initIpcClient()
{
m_ipcClient = new IpcClient(m_events, m_socketMultiplexer);
m_ipcClient = new IpcClient(m_events, m_socketMultiplexer.get());
m_ipcClient->connect();
m_events->adoptHandler(

View File

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

View File

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

View File

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