Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename SynchroRawImpl to SynchroImpl
[simgrid.git] / src / kernel / activity / Synchro.hpp
1 /* Copyright (c) 2007-2022. 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 #ifndef SIMGRID_KERNEL_ACTIVITY_SYNCHRO_RAW_HPP
7 #define SIMGRID_KERNEL_ACTIVITY_SYNCHRO_RAW_HPP
8
9 #include "src/kernel/activity/ActivityImpl.hpp"
10
11 #include <functional>
12
13 namespace simgrid {
14 namespace kernel {
15 namespace activity {
16
17 /** Used to implement mutexes, semaphores and conditions */
18 class XBT_PUBLIC SynchroImpl : public ActivityImpl_T<SynchroImpl> {
19   sg_host_t host_ = nullptr;
20   double timeout_ = -1;
21   std::function<void()> finish_callback_;
22
23 public:
24   explicit SynchroImpl(const std::function<void()>& finish_callback) : finish_callback_(finish_callback) {}
25   SynchroImpl& set_host(s4u::Host* host);
26   SynchroImpl& set_timeout(double timeout) override;
27
28   SynchroImpl* start();
29   void suspend() override;
30   void resume() override;
31   void cancel() override;
32   void post() override;
33   void set_exception(actor::ActorImpl* issuer) override;
34   void finish() override;
35 };
36 } // namespace activity
37 } // namespace kernel
38 } // namespace simgrid
39
40 #endif