Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allStorages() -> getStorageList(whereTo)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 5 Dec 2017 08:23:52 +0000 (09:23 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 5 Dec 2017 08:23:52 +0000 (09:23 +0100)
ChangeLog
examples/s4u/io-file-remote/s4u-io-file-remote.cpp
include/simgrid/s4u/Storage.hpp
src/msg/msg_io.cpp
src/s4u/s4u_storage.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp

index 22c53c2..f18d137 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,9 @@ SimGrid (3.18) NOT RELEASED YET (target: December 24 2017)
    Mailbox::getCname() instead to get a char*.
  - Storage::getName() changed to return a std::string, use
    Storage::getCname() instead to get a char*.
+ - simgrid::s4u::allStorages() becomes 
+   simgrid::s4u::getStorageList(whereTo) to have both allocation
+   and deallocation of the map in user space.
 
  MSG
  - Deprecate MSG_task_get_flops_amount(). Its semantic was weird:
index 13b59de..5ec1825 100644 (file)
@@ -58,7 +58,8 @@ int main(int argc, char** argv)
   e.loadPlatform(argv[1]);
   e.registerFunction("host", host);
   e.loadDeployment(argv[2]);
-  std::map<std::string, simgrid::s4u::Storage*>* allStorages = simgrid::s4u::allStorages();
+  std::map<std::string, simgrid::s4u::Storage*>* allStorages = new std::map<std::string, simgrid::s4u::Storage*>;
+  simgrid::s4u::getStorageList(allStorages);
 
   for (auto const& s : *allStorages) {
     XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", sg_storage_get_size_used(s.second) / INMEGA,
index f313e49..571c3b1 100644 (file)
@@ -21,7 +21,7 @@ extern template class XBT_PUBLIC() Extendable<simgrid::s4u::Storage>;
 }
 namespace s4u {
 
-XBT_ATTRIB_PUBLIC std::map<std::string, Storage*>* allStorages();
+XBT_ATTRIB_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
 
 XBT_PUBLIC_CLASS Storage : public simgrid::xbt::Extendable<Storage>
 {
index aff1939..0734919 100644 (file)
@@ -93,11 +93,12 @@ msg_storage_t MSG_storage_get_by_name(const char *name)
  */
 xbt_dynar_t MSG_storages_as_dynar()
 {
-  std::map<std::string, simgrid::s4u::Storage*>* storage_map = simgrid::s4u::allStorages();
+  std::map<std::string, simgrid::s4u::Storage*>* storage_list = new std::map<std::string, simgrid::s4u::Storage*>;
+  simgrid::s4u::getStorageList(storage_list);
   xbt_dynar_t res = xbt_dynar_new(sizeof(msg_storage_t),nullptr);
-  for (auto const& s : *storage_map)
+  for (auto const& s : *storage_list)
     xbt_dynar_push(res, &(s.second));
-  delete storage_map;
+  delete storage_list;
   return res;
 }
 
index b4920f5..d8f004a 100644 (file)
@@ -17,14 +17,10 @@ template class Extendable<simgrid::s4u::Storage>;
 
 namespace s4u {
 
-std::map<std::string, Storage*>* allStorages()
+void getStorageList(std::map<std::string, Storage*>* whereTo)
 {
-  std::unordered_map<std::string, surf::StorageImpl*>* map = surf::StorageImpl::storagesMap();
-  std::map<std::string, Storage*>* res                     = new std::map<std::string, Storage*>;
-  for (auto const& s : *map)
-    res->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
-
-  return res;
+  for (auto const& s : *surf::StorageImpl::storagesMap())
+    whereTo->insert({s.first, &(s.second->piface_)}); // Convert each entry into its interface
 }
 
 Storage* Storage::byName(std::string name)
index 9eb3c03..1f14a3e 100644 (file)
@@ -90,7 +90,8 @@ static void get_set_storage_data(const std::string& storage_name)
 
 static void dump_platform_storages()
 {
-  std::map<std::string, simgrid::s4u::Storage*>* storages = simgrid::s4u::allStorages();
+  std::map<std::string, simgrid::s4u::Storage*>* storages = new std::map<std::string, simgrid::s4u::Storage*>;
+  simgrid::s4u::getStorageList(storages);
 
   for (auto const& storage : *storages) {
     XBT_INFO("Storage %s is attached to %s", storage.first.c_str(), storage.second->getHost()->getCname());