Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / kernel / activity / Synchro.hpp
1 /* Copyright (c) 2007-2023. 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::kernel::activity {
14
15 /** Used to implement mutexes, semaphores and conditions */
16 class XBT_PUBLIC SynchroImpl : public ActivityImpl_T<SynchroImpl> {
17   sg_host_t host_ = nullptr;
18   double timeout_ = -1;
19   std::function<void()> finish_callback_;
20
21 public:
22   explicit SynchroImpl(const std::function<void()>& finish_callback) : finish_callback_(finish_callback) {}
23   SynchroImpl& set_host(s4u::Host* host);
24   SynchroImpl& set_timeout(double timeout) override;
25
26   SynchroImpl* start();
27   void suspend() override;
28   void resume() override;
29   void cancel() override;
30   void set_exception(actor::ActorImpl* issuer) override;
31   void finish() override;
32 };
33 } // namespace simgrid::kernel::activity
34
35 #endif