Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b4ed3931c6706421bfff05d279b7d9fd9ff10fad
[simgrid.git] / src / kernel / activity / SynchroRaw.hpp
1 /* Copyright (c) 2007-2021. 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 #include "surf/surf.hpp"
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 RawImpl : public ActivityImpl_T<RawImpl> {
19   sg_host_t host_ = nullptr;
20   double timeout_ = -1;
21   std::function<void()> finish_callback_;
22
23 public:
24   explicit RawImpl(const std::function<void()>& finish_callback) : finish_callback_(finish_callback) {}
25   RawImpl& set_host(s4u::Host* host);
26   RawImpl& set_timeout(double timeout) override;
27
28   RawImpl* start();
29   void suspend() override;
30   void resume() override;
31   void cancel() override;
32   void post() override;
33   void finish() override;
34 };
35 } // namespace activity
36 } // namespace kernel
37 } // namespace simgrid
38
39 #endif