1 /* Copyright (c) 2007-2019. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/kernel/activity/ActivityImpl.hpp"
8 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix_process);
14 ActivityImpl::~ActivityImpl()
17 surf_action_->unref();
18 XBT_DEBUG("Destroy activity %p", this);
19 surf_action_ = nullptr;
23 double ActivityImpl::get_remaining() const
25 return surf_action_ ? surf_action_->get_remains() : 0;
28 void ActivityImpl::suspend()
30 if (surf_action_ == nullptr)
32 XBT_VERB("This activity is suspended (remain: %f)", surf_action_->get_remains());
33 surf_action_->suspend();
37 void ActivityImpl::resume()
39 if (surf_action_ == nullptr)
41 XBT_VERB("This activity is resumed (remain: %f)", surf_action_->get_remains());
42 surf_action_->resume();
46 // boost::intrusive_ptr<Activity> support:
47 void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
49 activity->refcount_.fetch_add(1, std::memory_order_relaxed);
52 void intrusive_ptr_release(simgrid::kernel::activity::ActivityImpl* activity)
54 if (activity->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
55 std::atomic_thread_fence(std::memory_order_acquire);
59 xbt::signal<void(ActivityImpl const&)> ActivityImpl::on_resumed;
60 xbt::signal<void(ActivityImpl const&)> ActivityImpl::on_suspended;
63 } // namespace simgrid::kernel::activity::