Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
77e657063fa3508181022116b69353d5f220ab7c
[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   refcount_--;
23   if (refcount_ == 0)
24     delete this;
25 }