Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove superfluous refcounting.
[simgrid.git] / src / s4u / s4u_Comm.cpp
index 658097e..b39648d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2006-2019. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -32,15 +32,12 @@ Comm::~Comm()
 int Comm::wait_any_for(std::vector<CommPtr>* comms_in, double timeout)
 {
   // Map to dynar<Synchro*>:
-  xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), [](void* ptr) {
-    intrusive_ptr_release(*(simgrid::kernel::activity::ActivityImpl**)ptr);
-  });
+  xbt_dynar_t comms = xbt_dynar_new(sizeof(simgrid::kernel::activity::ActivityImpl*), nullptr);
   for (auto const& comm : *comms_in) {
     if (comm->state_ == Activity::State::INITED)
       comm->start();
     xbt_assert(comm->state_ == Activity::State::STARTED);
     simgrid::kernel::activity::ActivityImpl* ptr = comm->pimpl_.get();
-    intrusive_ptr_add_ref(ptr);
     xbt_dynar_push_as(comms, simgrid::kernel::activity::ActivityImpl*, ptr);
   }
   // Call the underlying simcall:
@@ -201,7 +198,7 @@ Comm* Comm::detach()
 
 Comm* Comm::cancel()
 {
-  simgrid::simix::simcall([this] { dynamic_cast<kernel::activity::CommImpl*>(pimpl_.get())->cancel(); });
+  simgrid::simix::simcall([this] { static_cast<kernel::activity::CommImpl*>(pimpl_.get())->cancel(); });
   state_ = State::CANCELED;
   return this;
 }