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)
{
delete command;
}
}
- scene->m_toBeCommittedList.clear();
+ clientCommandQueue.clear();
ExecutionResult returnValue = ExecutionFailed;
MOCK_METHOD0(getClientNotificationQueue, NotificationQueue&());
MOCK_METHOD0(getHealth, HealthCondition());
+
+ MOCK_METHOD1(getEnqueuedCommands, CommandList&(unsigned int clientPid));
};
#endif /* MockCommandExecutor_H_ */
#include "ApplicationReferenceMap.h"
#include "LayerType.h"
#include "ObjectType.h"
+#include "CommandList.h"
#include "NotificationQueue.h"
#include <pthread.h>
* \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
#include "ICommandExecutor.h"
#include "NotificationQueue.h"
+#include "CommandList.h"
#include <pthread.h>
class Scene;
class Configuration;
class PluginManager;
+typedef std::map<unsigned int, CommandList> CommandListMap;
typedef std::map<unsigned int, const char*> PidToProcessNameTable;
typedef std::list<IPlugin*> PluginList;
virtual HealthCondition getHealth();
+ virtual CommandList& getEnqueuedCommands(unsigned int clientPid);
+
private:
void printDebugInformation() const;
bool startAllRenderers(const int width, const int height, const char *displayName);
NotificationQueue m_clientNotificationQueue;
ApplicationReferenceMap* m_pApplicationReferenceMap;
PidToProcessNameTable m_pidToProcessNameTable;
+ CommandListMap m_EnqueuedCommands;
IHealth* m_pHealth;
pthread_t m_pWatchdogThread;
bool mHealthState;
return m_clientNotificationQueue;
}
+inline CommandList& Layermanager::getEnqueuedCommands(unsigned int clientPid)
+{
+ return m_EnqueuedCommands[clientPid];
+}
+
#endif /* _LAYERMANAGER_H_ */
void removeSurfaceFromAllSurfaceGroups(Surface* surface);
private:
- CommandList m_toBeCommittedList;
ShaderMap m_shaderMap;
pthread_mutex_t m_layerListMutex;
LayerGroupMap m_layerGroupMap;
#include "Layermanager.h"
#include "Log.h"
#include <iomanip>
+#include "CommandList.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);
+
+ // 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);
}
-bool Layermanager::enqueueCommand(ICommand* commandToBeExecuted)
+bool Layermanager::enqueueCommand(ICommand* command)
{
- unsigned int sizeBefore;
- unsigned int sizeAfter;
+ bool result = false;
- 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);
+ return result;
}
bool Layermanager::execute(ICommand* commandToBeExecuted)
return returnValue;
}
+