Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar
[simgrid.git] / src / simix / smx_private.h
1 /* Copyright (c) 2007-2010, 2012-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef _SIMIX_PRIVATE_H
8 #define _SIMIX_PRIVATE_H
9
10 #include <signal.h>
11 #include "src/kernel/context/Context.hpp"
12
13 /********************************** Simix Global ******************************/
14
15 namespace simgrid {
16 namespace simix {
17
18 class Global {
19 public:
20   smx_context_factory_t context_factory = nullptr;
21   xbt_dynar_t process_to_run = nullptr;
22   xbt_dynar_t process_that_ran = nullptr;
23   xbt_swag_t process_list = nullptr;
24   xbt_swag_t process_to_destroy = nullptr;
25   smx_actor_t maestro_process = nullptr;
26
27   // Maps function names to actor code:
28   std::unordered_map<std::string, simgrid::simix::ActorCodeFactory> registered_functions;
29
30   // This might be used when no corresponding function name is registered:
31   simgrid::simix::ActorCodeFactory default_function;
32
33   smx_creation_func_t create_process_function = nullptr;
34   void_pfn_smxprocess_t kill_process_function = nullptr;
35   /** Callback used when killing a SMX_process */
36   void_pfn_smxprocess_t cleanup_process_function = nullptr;
37   xbt_os_mutex_t mutex = nullptr;
38
39   std::vector<simgrid::xbt::Task<void()>> tasks;
40   std::vector<simgrid::xbt::Task<void()>> tasksTemp;
41 };
42
43 }
44 }
45
46 SG_BEGIN_DECL()
47
48 XBT_PUBLIC_DATA(std::unique_ptr<simgrid::simix::Global>) simix_global;
49
50 XBT_PUBLIC(void) SIMIX_clean();
51
52 /******************************** Exceptions *********************************/
53 /** @brief Ask to the provided simix process to raise the provided exception */
54 #define SMX_EXCEPTION(issuer, cat, val, msg) \
55   if (1) { \
56   smx_actor_t _smx_throw_issuer = (issuer); /* evaluate only once */ \
57   xbt_ex e(XBT_THROW_POINT, msg); \
58   e.category = cat; \
59   e.value = val; \
60   _smx_throw_issuer->exception = std::make_exception_ptr(e); \
61   } else ((void)0)
62
63 /* ******************************** File ************************************ */
64 typedef struct s_smx_file {
65   surf_file_t surf_file;
66   void* data;                   /**< @brief user data */
67 } s_smx_file_t;
68
69
70 SG_END_DECL()
71
72 #endif