1
0

cNetwork: Linux compilation fix.

This commit is contained in:
Mattes D 2015-01-09 11:20:19 +01:00
parent 6f5e267d58
commit b8b3409b74
2 changed files with 23 additions and 4 deletions

View File

@ -358,8 +358,8 @@ protected:
/** Converts LibEvent-generated log events into log messages in MCS log. */ /** Converts LibEvent-generated log events into log messages in MCS log. */
static void LogCallback(int a_Severity, const char * a_Msg); static void LogCallback(int a_Severity, const char * a_Msg);
/** Runs the thread that LibEvent uses to dispatch event. */ /** Implements the thread that runs LibEvent's event dispatcher loop. */
static void EventLoopThread(cNetworkSingleton * a_Self); static void RunEventLoop(cNetworkSingleton * a_Self);
}; };
@ -722,7 +722,8 @@ cNetworkSingleton::cNetworkSingleton(void)
} }
// Create the event loop thread: // Create the event loop thread:
std::thread::thread(EventLoopThread, this).detach(); std::thread EventLoopThread(RunEventLoop, this);
EventLoopThread.detach();
} }
@ -827,7 +828,7 @@ void cNetworkSingleton::LogCallback(int a_Severity, const char * a_Msg)
void cNetworkSingleton::EventLoopThread(cNetworkSingleton * a_Self) void cNetworkSingleton::RunEventLoop(cNetworkSingleton * a_Self)
{ {
event_base_loop(a_Self->m_EventBase, EVLOOP_NO_EXIT_ON_EMPTY); event_base_loop(a_Self->m_EventBase, EVLOOP_NO_EXIT_ON_EMPTY);
} }

View File

@ -22,6 +22,9 @@ public:
class cCallbacks class cCallbacks
{ {
public: public:
// Force a virtual destructor for all descendants:
virtual ~cCallbacks() {}
/** Called when there's data incoming from the remote peer. */ /** Called when there's data incoming from the remote peer. */
virtual void OnReceivedData(cTCPLink & a_Link, const char * a_Data, size_t a_Length) = 0; virtual void OnReceivedData(cTCPLink & a_Link, const char * a_Data, size_t a_Length) = 0;
@ -36,6 +39,9 @@ public:
typedef SharedPtr<cCallbacks> cCallbacksPtr; typedef SharedPtr<cCallbacks> cCallbacksPtr;
// Force a virtual destructor for all descendants:
virtual ~cTCPLink() {}
/** Queues the specified data for sending to the remote peer. /** Queues the specified data for sending to the remote peer.
Returns true on success, false on failure. Note that this success or failure only reports the queue status, not the actual data delivery. */ Returns true on success, false on failure. Note that this success or failure only reports the queue status, not the actual data delivery. */
virtual bool Send(const void * a_Data, size_t a_Length) = 0; virtual bool Send(const void * a_Data, size_t a_Length) = 0;
@ -86,6 +92,9 @@ class cServerHandle
friend class cNetwork; friend class cNetwork;
public: public:
// Force a virtual destructor for all descendants:
virtual ~cServerHandle() {}
/** Stops the server, no more incoming connections will be accepted. */ /** Stops the server, no more incoming connections will be accepted. */
virtual void Close(void) = 0; virtual void Close(void) = 0;
@ -105,6 +114,9 @@ public:
class cConnectCallbacks class cConnectCallbacks
{ {
public: public:
// Force a virtual destructor for all descendants:
virtual ~cConnectCallbacks() {}
/** Called when the Connect call succeeds. /** Called when the Connect call succeeds.
Provides the newly created link that can be used for communication. */ Provides the newly created link that can be used for communication. */
virtual void OnSuccess(cTCPLink & a_Link) = 0; virtual void OnSuccess(cTCPLink & a_Link) = 0;
@ -119,6 +131,9 @@ public:
class cListenCallbacks class cListenCallbacks
{ {
public: public:
// Force a virtual destructor for all descendants:
virtual ~cListenCallbacks() {}
/** Called when the TCP server created with Listen() accepts an incoming connection. /** Called when the TCP server created with Listen() accepts an incoming connection.
Provides the newly created Link that can be used for communication. */ Provides the newly created Link that can be used for communication. */
virtual void OnAccepted(cTCPLink & a_Link) = 0; virtual void OnAccepted(cTCPLink & a_Link) = 0;
@ -130,6 +145,9 @@ public:
class cResolveNameCallbacks class cResolveNameCallbacks
{ {
public: public:
// Force a virtual destructor for all descendants:
virtual ~cResolveNameCallbacks() {}
/** Called when the hostname is successfully resolved into an IP address. */ /** Called when the hostname is successfully resolved into an IP address. */
virtual void OnNameResolved(const AString & a_Name, const AString & a_IP) = 0; virtual void OnNameResolved(const AString & a_Name, const AString & a_IP) = 0;