Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cec22ac4a37a863a652ce874321cc83a5d5e7f8a
[simgrid.git] / src / kernel / context / ContextUnix.hpp
1 /* Copyright (c) 2009-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 #ifndef SIMGRID_SIMIX_UNIX_CONTEXT_HPP
7 #define SIMGRID_SIMIX_UNIX_CONTEXT_HPP
8
9 #include <ucontext.h> /* context relative declarations */
10
11 #include <atomic>
12 #include <cstdint>
13 #include <functional>
14 #include <vector>
15
16 #include <simgrid/simix.hpp>
17 #include <xbt/parmap.hpp>
18
19 #include "src/internal_config.h"
20 #include "src/kernel/context/ContextSwapped.hpp"
21
22 namespace simgrid {
23 namespace kernel {
24 namespace context {
25
26 class UContext : public SwappedContext {
27 public:
28   UContext(std::function<void()>&& code, actor::ActorImpl* actor, SwappedContextFactory* factory);
29
30   void swap_into(SwappedContext* to) override;
31
32 private:
33   ucontext_t uc_;         /* the ucontext that executes the code */
34 };
35
36 class UContextFactory : public SwappedContextFactory {
37 public:
38   UContext* create_context(std::function<void()>&& code, actor::ActorImpl* actor) override;
39 };
40 } // namespace context
41 } // namespace kernel
42 } // namespace simgrid
43
44 #endif