Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fixing codacy warnings on multi-core VM tests + using a dedicated platform file for...
[simgrid.git] / src / kernel / activity / ActivityImpl.cpp
1 /* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved.          */
2
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. */
5
6 #include "src/kernel/activity/ActivityImpl.hpp"
7
8 namespace simgrid {
9 namespace kernel {
10 namespace activity {
11
12 ActivityImpl::ActivityImpl()  = default;
13 ActivityImpl::~ActivityImpl() = default;
14
15 void ActivityImpl::ref()
16 {
17   // Atomic operation! Do not split in two instructions!
18   xbt_assert(refcount_ != 0);
19   refcount_++;
20 }
21
22 void ActivityImpl::unref()
23 {
24   xbt_assert(refcount_ > 0,
25              "This activity has a negative refcount! You can only call test() or wait() once per activity.");
26   refcount_--;
27   if (refcount_ == 0)
28     delete this;
29 }
30
31 // boost::intrusive_ptr<Activity> support:
32 void intrusive_ptr_add_ref(simgrid::kernel::activity::ActivityImpl* activity)
33 {
34   activity->ref();
35 }
36
37 void intrusive_ptr_release(simgrid::kernel::activity::ActivityImpl* activity)
38 {
39   activity->unref();
40 }
41 }
42 }
43 } // namespace simgrid::kernel::activity::