#include <boost/heap/pairing_heap.hpp>
#include <boost/optional.hpp>
#include <string>
+#include <string_view>
static constexpr double NO_MAX_DURATION = -1.0;
/** @brief Get the tracing category associated to the current action */
const std::string& get_category() const { return category_; }
/** @brief Set the tracing category of the current Action */
- void set_category(const std::string& category) { category_ = category; }
+ void set_category(std::string_view category) { category_ = category; }
/** @brief Get the sharing_penalty (RTT or 1/thread_count) of the current Action */
double get_sharing_penalty() const { return sharing_penalty_; };
*/
s4u::CommPtr put_async(T* data, size_t simulated_size_in_bytes)
{
- std::unique_lock<s4u::Mutex> lock(*mutex_);
+ std::unique_lock lock(*mutex_);
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, (size() < max_queue_size_) ? "can put" : "must wait");
*/
s4u::CommPtr get_async(T** data)
{
- std::unique_lock<s4u::Mutex> lock(*mutex_);
+ std::unique_lock lock(*mutex_);
s4u::CommPtr comm = nullptr;
XBT_CVERB(producer_consumer, empty() ? "must wait" : "can get");
while (empty())
#include <simgrid/forward.h>
#include <stdexcept>
#include <string>
+#include <string_view>
#include <vector>
#include <xbt/Extendable.hpp>
#include <xbt/asserts.h>
{
if(this == a)
throw std::invalid_argument("Cannot be its own successor");
- auto p = std::find_if(successors_.begin(), successors_.end(), [a](ActivityPtr const& i){ return i.get() == a.get(); });
- if (p != successors_.end())
+
+ if (std::any_of(begin(successors_), end(successors_), [a](ActivityPtr const& i) { return i.get() == a.get(); }))
throw std::invalid_argument("Dependency already exists");
successors_.push_back(a);
if(this == a)
throw std::invalid_argument("Cannot ask to remove itself from successors list");
- auto p = std::find_if(successors_.begin(), successors_.end(), [a](ActivityPtr const& i){ return i.get() == a.get(); });
- if (p != successors_.end()){
- successors_.erase(p);
- a->dependencies_.erase({this});
- } else
+ auto p =
+ std::find_if(successors_.begin(), successors_.end(), [a](ActivityPtr const& i) { return i.get() == a.get(); });
+ if (p == successors_.end())
throw std::invalid_argument("Dependency does not exist. Can not be removed.");
+
+ successors_.erase(p);
+ a->dependencies_.erase({this});
}
static std::set<Activity*>* vetoed_activities_;
Activity::remove_successor(a);
return static_cast<AnyActivity*>(this);
}
- AnyActivity* set_name(const std::string& name)
+ AnyActivity* set_name(std::string_view name)
{
name_ = name;
return static_cast<AnyActivity*>(this);
const std::string& get_name() const override { return name_; }
const char* get_cname() const override { return name_.c_str(); }
- AnyActivity* set_tracing_category(const std::string& category)
+ AnyActivity* set_tracing_category(std::string_view category)
{
xbt_assert(get_state() == State::INITED || get_state() == State::STARTING,
"Cannot change the tracing category of an activity after its start");