Cosmetic changes, removed unused and unimplemented 'stop protocol' support.
This commit is contained in:
parent
cf9ce6674c
commit
966d31dc45
@ -141,14 +141,14 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Called when the protocol is paused (by an other entity or by
|
||||
* itself). */
|
||||
virtual void pause() { }
|
||||
virtual void paused() { }
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Called when the protocol is used.
|
||||
*/
|
||||
virtual void unpause() { }
|
||||
virtual void unpaused() { }
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Called when the protocol is to be killed. */
|
||||
virtual void kill() {}
|
||||
virtual void terminated() {}
|
||||
// ------------------------------------------------------------------------
|
||||
/** \brief Method to get a protocol's type.
|
||||
* \return The protocol type. */
|
||||
|
@ -222,24 +222,6 @@ uint32_t ProtocolManager::requestStart(Protocol* protocol)
|
||||
return req.getProtocol()->getId();
|
||||
} // requestStart
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** \brief Asks the manager to stop a protocol.
|
||||
* This function will store the request, and process it at a time it is
|
||||
* thread-safe.
|
||||
* \param protocol : A pointer to the protocol to stop
|
||||
*/
|
||||
void ProtocolManager::requestStop(Protocol* protocol)
|
||||
{
|
||||
if (!protocol)
|
||||
return;
|
||||
// create the request
|
||||
ProtocolRequest req(PROTOCOL_REQUEST_STOP, protocol);
|
||||
// add it to the request stack
|
||||
pthread_mutex_lock(&m_requests_mutex);
|
||||
m_requests.push_back(req);
|
||||
pthread_mutex_unlock(&m_requests_mutex);
|
||||
} // requestStop
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** \brief Asks the manager to pause a protocol.
|
||||
* This function will store the request, and process it at a time it is
|
||||
@ -327,58 +309,35 @@ void ProtocolManager::startProtocol(Protocol *protocol)
|
||||
} // startProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ProtocolManager::stopProtocol(Protocol *protocol)
|
||||
{
|
||||
} // stopProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** \brief Pauses a protocol.
|
||||
* Pauses a protocol and tells it that it's being paused.
|
||||
* \param protocol : Protocol to pause.
|
||||
*/
|
||||
void ProtocolManager::pauseProtocol(Protocol *protocol)
|
||||
{
|
||||
assert(protocol->getState() == PROTOCOL_STATE_RUNNING);
|
||||
protocol->setState(PROTOCOL_STATE_PAUSED);
|
||||
|
||||
return;
|
||||
|
||||
// FIXME ... why so complicated???
|
||||
#ifdef XX
|
||||
// FIXME Does this need to be locked?
|
||||
for (unsigned int i = 0; i < m_protocols.getData().size(); i++)
|
||||
{
|
||||
//ProtocolInfo *pi = m_protocols.getData()[i];
|
||||
if (pi->m_protocol == protocol.m_protocol &&
|
||||
pi->m_state == PROTOCOL_STATE_RUNNING)
|
||||
{
|
||||
pi->m_state = PROTOCOL_STATE_PAUSED;
|
||||
pi->m_protocol->pause();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
protocol->paused();
|
||||
} // pauseProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** \brief Unpauses a protocol.
|
||||
* Unpauses a protocol and notifies it.
|
||||
* \param protocol : Protocol to unpause.
|
||||
*/
|
||||
void ProtocolManager::unpauseProtocol(Protocol *protocol)
|
||||
{
|
||||
assert(protocol->getState() == PROTOCOL_STATE_PAUSED);
|
||||
protocol->setState(PROTOCOL_STATE_RUNNING);
|
||||
protocol->unpause();
|
||||
//FIXME: why call protocol->unpause() (which would queue a new request and
|
||||
// then calls this function again) ... and why so complicated??
|
||||
#ifdef XX
|
||||
// FIXME Does this need to be locked??
|
||||
for (unsigned int i = 0; i < m_protocols.getData().size(); i++)
|
||||
{
|
||||
ProtocolInfo *p = m_protocols.getData()[i];
|
||||
if (p->m_protocol == protocol.m_protocol &&
|
||||
p->m_state == PROTOCOL_STATE_PAUSED)
|
||||
{
|
||||
p->m_state = PROTOCOL_STATE_RUNNING;
|
||||
p->m_protocol->unpause();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
protocol->unpaused();
|
||||
} // unpauseProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void ProtocolManager::protocolTerminated(Protocol *protocol)
|
||||
/** \brief Notes that a protocol is terminated.
|
||||
* Remove a protocol from the protocols vector.
|
||||
* \param protocol : Protocol concerned.
|
||||
*/
|
||||
void ProtocolManager::terminateProtocol(Protocol *protocol)
|
||||
{
|
||||
// Be sure that noone accesses the protocols vector while we erase a protocol
|
||||
m_protocols.lock();
|
||||
@ -400,7 +359,8 @@ void ProtocolManager::protocolTerminated(Protocol *protocol)
|
||||
protocol_type.c_str(), m_protocols.getData().size());
|
||||
pthread_mutex_unlock(&m_asynchronous_protocols_mutex);
|
||||
m_protocols.unlock();
|
||||
} // protocolTerminated
|
||||
protocol->terminated();
|
||||
} // terminateProtocol
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Sends the event to the corresponding protocol.
|
||||
@ -523,9 +483,6 @@ void ProtocolManager::asynchronousUpdate()
|
||||
case PROTOCOL_REQUEST_START:
|
||||
startProtocol(m_requests[i].getProtocol());
|
||||
break;
|
||||
case PROTOCOL_REQUEST_STOP:
|
||||
stopProtocol(m_requests[i].getProtocol());
|
||||
break;
|
||||
case PROTOCOL_REQUEST_PAUSE:
|
||||
pauseProtocol(m_requests[i].getProtocol());
|
||||
break;
|
||||
@ -533,7 +490,7 @@ void ProtocolManager::asynchronousUpdate()
|
||||
unpauseProtocol(m_requests[i].getProtocol());
|
||||
break;
|
||||
case PROTOCOL_REQUEST_TERMINATE:
|
||||
protocolTerminated(m_requests[i].getProtocol());
|
||||
terminateProtocol(m_requests[i].getProtocol());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ class STKPeer;
|
||||
enum ProtocolRequestType
|
||||
{
|
||||
PROTOCOL_REQUEST_START, //!< Start a protocol
|
||||
PROTOCOL_REQUEST_STOP, //!< Stop a protocol
|
||||
PROTOCOL_REQUEST_PAUSE, //!< Pause a protocol
|
||||
PROTOCOL_REQUEST_UNPAUSE, //!< Unpause a protocol
|
||||
PROTOCOL_REQUEST_TERMINATE //!< Terminate a protocol
|
||||
@ -100,7 +99,7 @@ typedef struct EventProcessingInfo
|
||||
* protocol and give it to this singleton. The protocols are updated in a
|
||||
* special thread, to ensure that they are processed independently from the
|
||||
* frames per second. Then, the management of protocols is thread-safe: any
|
||||
* object can start/pause/stop protocols whithout problems.
|
||||
* object can start/pause/... protocols whithout problems.
|
||||
*/
|
||||
class ProtocolManager : public AbstractSingleton<ProtocolManager>,
|
||||
public NoCopy
|
||||
@ -121,7 +120,6 @@ class ProtocolManager : public AbstractSingleton<ProtocolManager>,
|
||||
const NetworkString& message,
|
||||
bool reliable = true);
|
||||
virtual uint32_t requestStart(Protocol* protocol);
|
||||
virtual void requestStop(Protocol* protocol);
|
||||
virtual void requestPause(Protocol* protocol);
|
||||
virtual void requestUnpause(Protocol* protocol);
|
||||
virtual void requestTerminate(Protocol* protocol);
|
||||
@ -145,30 +143,9 @@ class ProtocolManager : public AbstractSingleton<ProtocolManager>,
|
||||
uint32_t getNextProtocolId();
|
||||
|
||||
virtual void startProtocol(Protocol *protocol);
|
||||
/*!
|
||||
* \brief Stops a protocol.
|
||||
* Coes nothing. Noone can stop running protocols for now.
|
||||
* \param protocol : Protocol to stop.
|
||||
*/
|
||||
virtual void stopProtocol(Protocol *protocol);
|
||||
/*!
|
||||
* \brief Pauses a protocol.
|
||||
* Pauses a protocol and tells it that it's being paused.
|
||||
* \param protocol : Protocol to pause.
|
||||
*/
|
||||
virtual void pauseProtocol(Protocol *protocol);
|
||||
/*!
|
||||
* \brief Unpauses a protocol.
|
||||
* Unpauses a protocol and notifies it.
|
||||
* \param protocol : Protocol to unpause.
|
||||
*/
|
||||
virtual void unpauseProtocol(Protocol *protocol);
|
||||
/*!
|
||||
* \brief Notes that a protocol is terminated.
|
||||
* Remove a protocol from the protocols vector.
|
||||
* \param protocol : Protocol concerned.
|
||||
*/
|
||||
virtual void protocolTerminated(Protocol *protocol);
|
||||
virtual void pauseProtocol(Protocol *protocol);
|
||||
virtual void unpauseProtocol(Protocol *protocol);
|
||||
virtual void terminateProtocol(Protocol *protocol);
|
||||
|
||||
bool sendEvent(EventProcessingInfo* event, bool synchronous);
|
||||
|
||||
@ -181,7 +158,7 @@ class ProtocolManager : public AbstractSingleton<ProtocolManager>,
|
||||
/** Contains the network events to pass to protocols. */
|
||||
Synchronised<std::vector<EventProcessingInfo> > m_events_to_process;
|
||||
|
||||
/** Contains the requests to start/stop etc... protocols. */
|
||||
/** Contains the requests to start/pause etc... protocols. */
|
||||
std::vector<ProtocolRequest> m_requests;
|
||||
/*! \brief The next id to assign to a protocol.
|
||||
* This value is incremented by 1 each time a protocol is started.
|
||||
|
Loading…
Reference in New Issue
Block a user