Made start/terminate/pause/unpause-Protocol private, so that now all
calls to those functions from the ProtocolManager event loop (which avoids locking problems).
This commit is contained in:
@@ -153,6 +153,12 @@ private:
|
||||
uint32_t getNextProtocolId();
|
||||
bool sendEvent(EventProcessingInfo* event, bool synchronous);
|
||||
|
||||
virtual void startProtocol(Protocol *protocol);
|
||||
virtual void terminateProtocol(Protocol *protocol);
|
||||
virtual void asynchronousUpdate();
|
||||
virtual void pauseProtocol(Protocol *protocol);
|
||||
virtual void unpauseProtocol(Protocol *protocol);
|
||||
|
||||
public:
|
||||
virtual void abort();
|
||||
virtual void propagateEvent(Event* event);
|
||||
@@ -171,12 +177,7 @@ public:
|
||||
virtual void requestPause(Protocol* protocol);
|
||||
virtual void requestUnpause(Protocol* protocol);
|
||||
virtual void requestTerminate(Protocol* protocol);
|
||||
virtual void startProtocol(Protocol *protocol);
|
||||
virtual void pauseProtocol(Protocol *protocol);
|
||||
virtual void unpauseProtocol(Protocol *protocol);
|
||||
virtual void terminateProtocol(Protocol *protocol);
|
||||
virtual void update();
|
||||
virtual void asynchronousUpdate();
|
||||
virtual Protocol* getProtocol(uint32_t id);
|
||||
virtual Protocol* getProtocol(ProtocolType type);
|
||||
}; // class ProtocolManager
|
||||
|
||||
@@ -111,7 +111,7 @@ void ConnectToServer::asynchronousUpdate()
|
||||
m_current_protocol->requestStart();
|
||||
// This protocol will be unpaused in the callback from
|
||||
// GetPublicAddress
|
||||
ProtocolManager::getInstance()->pauseProtocol(this);
|
||||
requestPause();
|
||||
m_state = GETTING_SELF_ADDRESS;
|
||||
break;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ void ConnectToServer::asynchronousUpdate()
|
||||
m_state = GOT_SERVER_ADDRESS;
|
||||
// Pause this protocol till GetPeerAddress finishes.
|
||||
// The callback then will unpause this protocol/
|
||||
ProtocolManager::getInstance()->pauseProtocol(this);
|
||||
requestPause();
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -266,12 +266,12 @@ void ConnectToServer::callback(Protocol *protocol)
|
||||
case GETTING_SELF_ADDRESS:
|
||||
// The GetPublicAddress protocol stores our address in
|
||||
// STKHost, so we only need to unpause this protocol
|
||||
ProtocolManager::getInstance()->unpauseProtocol(this);
|
||||
requestUnpause();
|
||||
break;
|
||||
case GOT_SERVER_ADDRESS:
|
||||
// Get the server address from the protocol.
|
||||
m_server_address.copy(((GetPeerAddress*)protocol)->getAddress());
|
||||
ProtocolManager::getInstance()->unpauseProtocol(this);
|
||||
requestUnpause();
|
||||
break;
|
||||
default:
|
||||
Log::error("ConnectToServer",
|
||||
|
||||
@@ -124,7 +124,7 @@ void ServerLobbyRoomProtocol::update()
|
||||
m_current_protocol->requestStart();
|
||||
m_state = GETTING_PUBLIC_ADDRESS;
|
||||
// The callback from GetPublicAddress will wake this protocol up
|
||||
ProtocolManager::getInstance()->pauseProtocol(this);
|
||||
requestPause();
|
||||
break;
|
||||
case GETTING_PUBLIC_ADDRESS:
|
||||
{
|
||||
@@ -170,7 +170,7 @@ void ServerLobbyRoomProtocol::update()
|
||||
*/
|
||||
void ServerLobbyRoomProtocol::callback(Protocol *protocol)
|
||||
{
|
||||
ProtocolManager::getInstance()->unpauseProtocol(this);
|
||||
requestUnpause();
|
||||
} // callback
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user