Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill a redundent oldish API to the activity refcounting
[simgrid.git] / src / kernel / activity / ActivityImpl.cpp
1 /* Copyright (c) 2007-2016. 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 simgrid::kernel::activity::ActivityImpl::ActivityImpl() = default;
9 simgrid::kernel::activity::ActivityImpl::~ActivityImpl() = default;
10
11 void simgrid::kernel::activity::ActivityImpl::ref()
12 {
13   // Atomic operation! Do not split in two instructions!
14   xbt_assert(refcount_ != 0);
15   refcount_++;
16 }
17
18 void simgrid::kernel::activity::ActivityImpl::unref()
19 {
20   xbt_assert(refcount_ > 0,
21              "This activity has a negative refcount! You can only call test() or wait() once per activity.");
22
23   // Atomic operation! Do not split in two instructions!
24   auto count = --refcount_;
25   if (count == 0)
26     delete this;
27 }