#define SIMGRID_S4U_ACTIVITY_HPP
#include "xbt/asserts.h"
+#include <atomic>
#include <simgrid/forward.h>
#include <xbt/signal.hpp>
std::string name_ = "";
std::string tracing_category_ = "";
void* user_data_ = nullptr;
+ std::atomic_int_fast32_t refcount_{0};
public:
+#ifndef DOXYGEN
+ friend XBT_PUBLIC void intrusive_ptr_release(AnyActivity* a)
+ {
+ if (a->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ delete a;
+ }
+ }
+ friend XBT_PUBLIC void intrusive_ptr_add_ref(AnyActivity* a) { a->refcount_.fetch_add(1, std::memory_order_relaxed); }
+#endif
AnyActivity* set_name(const std::string& name)
{
xbt_assert(get_state() == State::INITED, "Cannot change the name of an activity after its start");
#include <simgrid/forward.h>
#include <simgrid/s4u/Activity.hpp>
-#include <atomic>
#include <string>
#include <vector>
void* src_buff_ = nullptr;
size_t src_buff_size_ = sizeof(void*);
std::string tracing_category_ = "";
- std::atomic_int_fast32_t refcount_{0};
/* FIXME: expose these elements in the API */
bool detached_ = false;
int (*match_fun_)(void*, void*, kernel::activity::CommImpl*) = nullptr;
public:
#ifndef DOXYGEN
- friend XBT_PUBLIC void intrusive_ptr_release(Comm* c);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
friend Mailbox; // Factory of comms
#endif
#include <simgrid/s4u/Actor.hpp>
#include <xbt/ex.h>
-#include <atomic>
-
namespace simgrid {
namespace s4u {
double priority_ = 1.0;
double bound_ = 0.0;
double timeout_ = 0.0;
- std::atomic_int_fast32_t refcount_{0};
protected:
Exec();
- virtual ~Exec() = default;
public:
+ virtual ~Exec() = default;
#ifndef DOXYGEN
Exec(Exec const&) = delete;
Exec& operator=(Exec const&) = delete;
friend ExecSeq;
friend ExecPar;
- friend XBT_PUBLIC void intrusive_ptr_release(Exec* e);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
#endif
static xbt::signal<void(Actor const&, Exec const&)> on_start;
static xbt::signal<void(Actor const&, Exec const&)> on_completion;
#include <simgrid/forward.h>
#include <simgrid/s4u/Activity.hpp>
-#include <atomic>
#include <string>
namespace simgrid {
Disk* disk_ = nullptr;
sg_size_t size_ = 0;
OpType type_ = OpType::READ;
- std::atomic_int_fast32_t refcount_{0};
explicit Io(sg_storage_t storage, sg_size_t size, OpType type);
explicit Io(sg_disk_t disk, sg_size_t size, OpType type);
public:
#ifndef DOXYGEN
- friend XBT_PUBLIC void intrusive_ptr_release(simgrid::s4u::Io* i);
- friend XBT_PUBLIC void intrusive_ptr_add_ref(simgrid::s4u::Io* i);
friend Disk; // Factory of IOs
friend Storage; // Factory of IOs
#endif
return sender_ ? sender_->ciface() : nullptr;
}
-void intrusive_ptr_release(simgrid::s4u::Comm* c)
-{
- if (c->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete c;
- }
-}
-void intrusive_ptr_add_ref(simgrid::s4u::Comm* c)
-{
- c->refcount_.fetch_add(1, std::memory_order_relaxed);
-}
} // namespace s4u
} // namespace simgrid
return this;
}
-void intrusive_ptr_release(simgrid::s4u::Exec* e)
-{
- if (e->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete e;
- }
-}
-
-void intrusive_ptr_add_ref(simgrid::s4u::Exec* e)
-{
- e->refcount_.fetch_add(1, std::memory_order_relaxed);
-}
-
/** @brief change the execution bound
* This means changing the maximal amount of flops per second that it may consume, regardless of what the host may
* deliver. Currently, this cannot be changed once the exec started.
[this]() { return boost::static_pointer_cast<kernel::activity::IoImpl>(pimpl_)->get_performed_ioops(); });
}
-void intrusive_ptr_release(simgrid::s4u::Io* i)
-{
- if (i->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
- std::atomic_thread_fence(std::memory_order_acquire);
- delete i;
- }
-}
-
-void intrusive_ptr_add_ref(simgrid::s4u::Io* i)
-{
- i->refcount_.fetch_add(1, std::memory_order_relaxed);
-}
} // namespace s4u
} // namespace simgrid