|
|
@@ -3,17 +3,18 @@
|
|
|
#include "containerManager.h"
|
|
|
#include <globalAllocator/globalAllocator.h>
|
|
|
|
|
|
-bool pika::ContainerManager::createContainer
|
|
|
-(std::string name, pika::ContainerInformation containerInformation,
|
|
|
+pika::containerId_t pika::ContainerManager::createContainer
|
|
|
+(pika::ContainerInformation containerInformation,
|
|
|
pika::DllLoader &dllLoader, pika::LogManager &logManager)
|
|
|
-{
|
|
|
- //todo containers should have an id rather than name
|
|
|
- if (runningContainers.find(name) != runningContainers.end())
|
|
|
- {
|
|
|
- logManager.log((std::string("Container name already exists: ") + name).c_str(), pika::logError);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
+{
|
|
|
+ containerId_t id = ++idCounter;
|
|
|
+
|
|
|
+ //not necessary if this is the only things that assigns ids.
|
|
|
+ //if (runningContainers.find(id) != runningContainers.end())
|
|
|
+ //{
|
|
|
+ // logManager.log((std::string("Container id already exists: #") + std::to_string(id)).c_str(), pika::logError);
|
|
|
+ // return false;
|
|
|
+ //}
|
|
|
|
|
|
pika::RuntimeContainer container = {};
|
|
|
container.arena.allocateStaticMemory(containerInformation); //this just allocates the staic memory
|
|
|
@@ -28,12 +29,12 @@ bool pika::ContainerManager::createContainer
|
|
|
{
|
|
|
dllLoader.resetAllocatorDllRealm();
|
|
|
|
|
|
- logManager.log((std::string("Couldn't construct container: ") + name).c_str(), pika::logError);
|
|
|
+ logManager.log((std::string("Couldn't construct container: #") + std::to_string(id)).c_str(), pika::logError);
|
|
|
|
|
|
container.arena.dealocateStaticMemory(); //static memory
|
|
|
free(container.allocator.originalBaseMemory); //heap memory
|
|
|
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
}
|
|
|
dllLoader.resetAllocatorDllRealm();
|
|
|
|
|
|
@@ -49,9 +50,9 @@ bool pika::ContainerManager::createContainer
|
|
|
container.pointer->create(container.requestedContainerInfo); //this calls create() (from the dll realm)
|
|
|
dllLoader.resetAllocatorDllRealm();//sets the global allocator back to standard (used for runtime realm)
|
|
|
|
|
|
- runningContainers[name] = container;
|
|
|
+ runningContainers[id] = container;
|
|
|
|
|
|
- return true;
|
|
|
+ return id;
|
|
|
}
|
|
|
|
|
|
void pika::ContainerManager::init()
|
|
|
@@ -71,13 +72,13 @@ void pika::ContainerManager::update(pika::DllLoader &dllLoader,
|
|
|
|
|
|
}
|
|
|
|
|
|
-bool pika::ContainerManager::destroyContainer(std::string name, pika::DllLoader &dllLoader,
|
|
|
+bool pika::ContainerManager::destroyContainer(containerId_t id, pika::DllLoader &dllLoader,
|
|
|
pika::LogManager &logManager)
|
|
|
{
|
|
|
- auto c = runningContainers.find(name);
|
|
|
+ auto c = runningContainers.find(id);
|
|
|
if (c == runningContainers.end())
|
|
|
{
|
|
|
- logManager.log((std::string("Couldn't find container for destruction: ") + name).c_str(),
|
|
|
+ logManager.log((std::string("Couldn't find container for destruction: #") + std::to_string(id)).c_str(),
|
|
|
pika::logError);
|
|
|
return false;
|
|
|
}
|