Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8d74f2cb0ed659d6f44bc4ec8bec932e66bbfb46
[simgrid.git] / src / kernel / activity / SemaphoreImpl.cpp
1 /* Copyright (c) 2019. 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/SemaphoreImpl.hpp"
7
8 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_semaphore, simix_synchro, "Semaphore kernel-space implementation");
9
10 namespace simgrid {
11 namespace kernel {
12 namespace activity {
13
14 void SemaphoreImpl::release()
15 {
16   XBT_DEBUG("Sem release semaphore %p", this);
17
18   if (not sleeping_.empty()) {
19     auto& actor = sleeping_.front();
20     sleeping_.pop_front();
21     actor.waiting_synchro = nullptr;
22     SIMIX_simcall_answer(&actor.simcall);
23   } else {
24     value_++;
25   }
26 }
27
28 } // namespace activity
29 } // namespace kernel
30 } // namespace simgrid