A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
deal with dependencies for Io too
[simgrid.git]
/
src
/
kernel
/
activity
/
SemaphoreImpl.hpp
diff --git
a/src/kernel/activity/SemaphoreImpl.hpp
b/src/kernel/activity/SemaphoreImpl.hpp
index
e6dc57d
..
361c7cf
100644
(file)
--- a/
src/kernel/activity/SemaphoreImpl.hpp
+++ b/
src/kernel/activity/SemaphoreImpl.hpp
@@
-1,10
+1,10
@@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2019
-2020
. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
_
-#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
_
+#ifndef SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
+#define SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
#include <atomic>
#include <boost/intrusive/list.hpp>
#include <atomic>
#include <boost/intrusive/list.hpp>
@@
-19,10
+19,9
@@
namespace activity {
class XBT_PUBLIC SemaphoreImpl {
std::atomic_int_fast32_t refcount_{1};
unsigned int value_;
class XBT_PUBLIC SemaphoreImpl {
std::atomic_int_fast32_t refcount_{1};
unsigned int value_;
-
-public:
actor::SynchroList sleeping_; /* list of sleeping actors*/
actor::SynchroList sleeping_; /* list of sleeping actors*/
+public:
explicit SemaphoreImpl(unsigned int value) : value_(value){};
~SemaphoreImpl() = default;
explicit SemaphoreImpl(unsigned int value) : value_(value){};
~SemaphoreImpl() = default;
@@
-32,8
+31,10
@@
public:
void acquire(actor::ActorImpl* issuer, double timeout);
void release();
bool would_block() { return (value_ == 0); }
void acquire(actor::ActorImpl* issuer, double timeout);
void release();
bool would_block() { return (value_ == 0); }
+ void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
unsigned int get_capacity() { return value_; }
unsigned int get_capacity() { return value_; }
+ bool is_used() { return not sleeping_.empty(); }
friend void intrusive_ptr_add_ref(SemaphoreImpl* sem)
{
friend void intrusive_ptr_add_ref(SemaphoreImpl* sem)
{
@@
-50,4
+51,4
@@
public:
} // namespace kernel
} // namespace simgrid
} // namespace kernel
} // namespace simgrid
-#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP
_
*/
+#endif /* SIMGRID_KERNEL_ACTIVITY_SEMAPHOREIMPL_HPP */