all asynchronous commands get enqueued and are executed by the client
using the commit command.
Now there is a separate command queue for each connected client and a client
can only commit commands, that have been sent by this client.
Signed-off-by: Timo Lotterbach <timo.lotterbach@bmw-carit.de>
bool success = true;
bool redraw = false;
bool success = true;
bool redraw = false;
- Scene* scene = (executor->getScene());
+ unsigned int commitCommandPid = getSenderPid();
- CommandListIterator iter = scene->m_toBeCommittedList.begin();
- CommandListIterator iterEnd = scene->m_toBeCommittedList.end();
+ CommandList& clientCommandQueue = executor->getEnqueuedCommands(commitCommandPid);
+ CommandListIterator iter = clientCommandQueue.begin();
+ CommandListIterator iterEnd = clientCommandQueue.end();
for (; iter != iterEnd; ++iter)
{
for (; iter != iterEnd; ++iter)
{
- scene->m_toBeCommittedList.clear();
+ clientCommandQueue.clear();
ExecutionResult returnValue = ExecutionFailed;
ExecutionResult returnValue = ExecutionFailed;
MOCK_METHOD0(getClientNotificationQueue, NotificationQueue&());
MOCK_METHOD0(getHealth, HealthCondition());
MOCK_METHOD0(getClientNotificationQueue, NotificationQueue&());
MOCK_METHOD0(getHealth, HealthCondition());
+
+ MOCK_METHOD1(getEnqueuedCommands, CommandList&(unsigned int clientPid));
};
#endif /* MockCommandExecutor_H_ */
};
#endif /* MockCommandExecutor_H_ */
#include "ApplicationReferenceMap.h"
#include "LayerType.h"
#include "ObjectType.h"
#include "ApplicationReferenceMap.h"
#include "LayerType.h"
#include "ObjectType.h"
+#include "CommandList.h"
#include "NotificationQueue.h"
#include <pthread.h>
#include "NotificationQueue.h"
#include <pthread.h>
* \return reference to current list of updated scene elements
*/
virtual NotificationQueue& getClientNotificationQueue() = 0;
* \return reference to current list of updated scene elements
*/
virtual NotificationQueue& getClientNotificationQueue() = 0;
+
+ /**
+ * \brief get the list of enqueued commands for a client
+ * \ingroup ServiceAPI
+ * \param[in] clientPid process id of client
+ * \return Reference to command list for client
+ */
+ virtual CommandList& getEnqueuedCommands(unsigned int clientPid) = 0;
+
/**
* \brief get system health state
* \ingroup ServiceAPI
/**
* \brief get system health state
* \ingroup ServiceAPI
#include "ICommandExecutor.h"
#include "NotificationQueue.h"
#include "ICommandExecutor.h"
#include "NotificationQueue.h"
+#include "CommandList.h"
#include <pthread.h>
class Scene;
#include <pthread.h>
class Scene;
class Configuration;
class PluginManager;
class Configuration;
class PluginManager;
+typedef std::map<unsigned int, CommandList> CommandListMap;
typedef std::map<unsigned int, const char*> PidToProcessNameTable;
typedef std::list<IPlugin*> PluginList;
typedef std::map<unsigned int, const char*> PidToProcessNameTable;
typedef std::list<IPlugin*> PluginList;
virtual HealthCondition getHealth();
virtual HealthCondition getHealth();
+ virtual CommandList& getEnqueuedCommands(unsigned int clientPid);
+
private:
void printDebugInformation() const;
bool startAllRenderers(const int width, const int height, const char *displayName);
private:
void printDebugInformation() const;
bool startAllRenderers(const int width, const int height, const char *displayName);
NotificationQueue m_clientNotificationQueue;
ApplicationReferenceMap* m_pApplicationReferenceMap;
PidToProcessNameTable m_pidToProcessNameTable;
NotificationQueue m_clientNotificationQueue;
ApplicationReferenceMap* m_pApplicationReferenceMap;
PidToProcessNameTable m_pidToProcessNameTable;
+ CommandListMap m_EnqueuedCommands;
IHealth* m_pHealth;
pthread_t m_pWatchdogThread;
bool mHealthState;
IHealth* m_pHealth;
pthread_t m_pWatchdogThread;
bool mHealthState;
return m_clientNotificationQueue;
}
return m_clientNotificationQueue;
}
+inline CommandList& Layermanager::getEnqueuedCommands(unsigned int clientPid)
+{
+ return m_EnqueuedCommands[clientPid];
+}
+
#endif /* _LAYERMANAGER_H_ */
#endif /* _LAYERMANAGER_H_ */
void removeSurfaceFromAllSurfaceGroups(Surface* surface);
private:
void removeSurfaceFromAllSurfaceGroups(Surface* surface);
private:
- CommandList m_toBeCommittedList;
ShaderMap m_shaderMap;
pthread_mutex_t m_layerListMutex;
LayerGroupMap m_layerGroupMap;
ShaderMap m_shaderMap;
pthread_mutex_t m_layerListMutex;
LayerGroupMap m_layerGroupMap;
#include "Layermanager.h"
#include "Log.h"
#include <iomanip>
#include "Layermanager.h"
#include "Log.h"
#include <iomanip>
+#include "CommandList.h"
#include "LayerList.h"
#include "ICommand.h"
#include "ICommunicator.h"
#include "LayerList.h"
#include "ICommand.h"
#include "ICommunicator.h"
LOG_INFO("LayerManagerService", "Disconnect from application " << getSenderName(client) << "(" << pid << ")");
m_pApplicationReferenceMap->erase(client);
m_pidToProcessNameTable.erase(pid);
LOG_INFO("LayerManagerService", "Disconnect from application " << getSenderName(client) << "(" << pid << ")");
m_pApplicationReferenceMap->erase(client);
m_pidToProcessNameTable.erase(pid);
+
+ // if pid = 0, the client did not send ServiceConnect.
+ // since many client may use this configuration, we must
+ // not discard any pending commands here: we could discard
+ // commands of currently running applications
+ if (0 != pid)
+ {
+ m_EnqueuedCommands.erase(pid);
+ }
return (status == ExecutionSuccess || status == ExecutionSuccessRedraw);
}
return (status == ExecutionSuccess || status == ExecutionSuccessRedraw);
}
-bool Layermanager::enqueueCommand(ICommand* commandToBeExecuted)
+bool Layermanager::enqueueCommand(ICommand* command)
- unsigned int sizeBefore;
- unsigned int sizeAfter;
- m_pScene->lockScene();
- sizeBefore = m_pScene->m_toBeCommittedList.size();
- m_pScene->m_toBeCommittedList.push_back(commandToBeExecuted);
- sizeAfter = m_pScene->m_toBeCommittedList.size();
- m_pScene->unlockScene();
+ if (command)
+ {
+ const unsigned int commandPid = command->getSenderPid();
+ m_EnqueuedCommands[commandPid].push_back(command);
+ result = true;
- unsigned int commandPid = commandToBeExecuted->getSenderPid();
- LOG_DEBUG("LayerManagerService", "enqueued " << commandToBeExecuted->getString()
- << " from " << getSenderName(commandPid) << "(" << commandPid << ")"
- << ((sizeAfter == sizeBefore + 1) ? "+" : "-"));
+ LOG_DEBUG("LayerManagerService", "enqueued " << command->getString()
+ << " from " << getSenderName(commandPid) << "(" << commandPid << ")"
+ << (result ? "+" : "-"));
+ }
- // if queue size increased by 1, enqueue command was successful
- return (sizeAfter == sizeBefore + 1);
}
bool Layermanager::execute(ICommand* commandToBeExecuted)
}
bool Layermanager::execute(ICommand* commandToBeExecuted)