Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move ASan related instructions around context swapping into SwappedContext.
[simgrid.git] / src / kernel / context / ContextUnix.hpp
1 /* Copyright (c) 2009-2020. 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_CONTEXT_UNIX_CONTEXT_HPP
7 #define SIMGRID_KERNEL_CONTEXT_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 private:
31   ucontext_t uc_;         /* the ucontext that executes the code */
32
33   void swap_into_for_real(SwappedContext* to) override;
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