Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
96a19143c9519255ec31d2828c6d6f415f5528f4
[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, smx_actor_t 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   Context* create_context(std::function<void()>&& code, smx_actor_t actor) override;
39 };
40 }}} // namespace
41
42 #endif