Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Mark all of simix.h as deprecated.
[simgrid.git] / include / simgrid / actor.h
1 /* Copyright (c) 2018-2022. 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 INCLUDE_SIMGRID_ACTOR_H_
7 #define INCLUDE_SIMGRID_ACTOR_H_
8
9 #include <simgrid/forward.h>
10 #include <xbt/base.h>
11 #include <xbt/dict.h>
12
13 /* C interface */
14 SG_BEGIN_DECL
15 /** @brief Actor datatype.
16     @ingroup m_actor_management
17
18     An actor may be defined as a <em>code</em>, with some <em>private data</em>, executing in a <em>location</em>.
19
20     You should not access directly to the fields of the pointed structure, but always use the provided API to interact
21     with actors.
22  */
23 XBT_PUBLIC size_t sg_actor_count();
24 XBT_PUBLIC sg_actor_t* sg_actor_list();
25
26 XBT_PUBLIC sg_actor_t sg_actor_create_(const char* name, sg_host_t host, xbt_main_func_t code, int argc,
27                                        const char* const* argv);
28 static inline sg_actor_t sg_actor_create(const char* name, sg_host_t host, xbt_main_func_t code, int argc,
29                                          char* const* argv)
30 {
31   return sg_actor_create_(name, host, code, argc, (const char* const*)argv);
32 }
33 XBT_PUBLIC sg_actor_t sg_actor_init(const char* name, sg_host_t host);
34 /** Start the previously initialized actor.
35  *
36  * Note that argv is copied over, so you should free your own copy once the actor is started. */
37 XBT_PUBLIC void sg_actor_start_(sg_actor_t actor, xbt_main_func_t code, int argc, const char* const* argv);
38 static inline void sg_actor_start(sg_actor_t actor, xbt_main_func_t code, int argc, char* const* argv)
39 {
40   sg_actor_start_(actor, code, argc, (const char* const*)argv);
41 }
42 XBT_PUBLIC void sg_actor_set_stacksize(sg_actor_t actor, unsigned size);
43
44 XBT_ATTRIB_NORETURN XBT_PUBLIC void sg_actor_exit();
45 XBT_PUBLIC void sg_actor_on_exit(void_f_int_pvoid_t fun, void* data);
46
47 XBT_PUBLIC aid_t sg_actor_get_pid(const_sg_actor_t actor);
48 XBT_PUBLIC aid_t sg_actor_get_ppid(const_sg_actor_t actor);
49 XBT_PUBLIC sg_actor_t sg_actor_by_pid(aid_t pid);
50 XBT_PUBLIC const char* sg_actor_get_name(const_sg_actor_t actor);
51 XBT_PUBLIC sg_host_t sg_actor_get_host(const_sg_actor_t actor);
52 XBT_PUBLIC const char* sg_actor_get_property_value(const_sg_actor_t actor, const char* name);
53 XBT_PUBLIC xbt_dict_t sg_actor_get_properties(const_sg_actor_t actor);
54 XBT_PUBLIC void sg_actor_suspend(sg_actor_t actor);
55 XBT_PUBLIC void sg_actor_resume(sg_actor_t actor);
56 XBT_PUBLIC int sg_actor_is_suspended(const_sg_actor_t actor);
57 XBT_PUBLIC sg_actor_t sg_actor_restart(sg_actor_t actor);
58 XBT_PUBLIC void sg_actor_set_auto_restart(sg_actor_t actor, int auto_restart);
59 XBT_PUBLIC void sg_actor_daemonize(sg_actor_t actor);
60 XBT_PUBLIC int sg_actor_is_daemon(const_sg_actor_t actor);
61
62 XBT_PUBLIC void sg_actor_set_host(sg_actor_t actor, sg_host_t host);
63 XBT_PUBLIC void sg_actor_join(const_sg_actor_t actor, double timeout);
64 XBT_PUBLIC void sg_actor_kill(sg_actor_t actor);
65 XBT_PUBLIC void sg_actor_kill_all();
66 XBT_PUBLIC void sg_actor_set_kill_time(sg_actor_t actor, double kill_time);
67 XBT_PUBLIC void sg_actor_yield();
68 XBT_PUBLIC void sg_actor_sleep_for(double duration);
69 XBT_PUBLIC void sg_actor_sleep_until(double wakeup_time);
70 XBT_PUBLIC sg_actor_t sg_actor_attach(const char* name, void* data, sg_host_t host, xbt_dict_t properties);
71 XBT_PUBLIC void sg_actor_detach();
72 XBT_PUBLIC sg_actor_t sg_actor_self();
73 XBT_PUBLIC aid_t sg_actor_self_get_pid();
74 XBT_PUBLIC aid_t sg_actor_self_get_ppid();
75 XBT_PUBLIC const char* sg_actor_self_get_name();
76 XBT_PUBLIC void* sg_actor_self_get_data();
77 XBT_PUBLIC void sg_actor_self_set_data(void* data);
78 XBT_PUBLIC void sg_actor_execute(double flops);
79 XBT_PUBLIC void sg_actor_execute_with_priority(double flops, double priority);
80 void sg_actor_parallel_execute(int host_nb, sg_host_t* host_list, double* flops_amount, double* bytes_amount);
81 XBT_PUBLIC void sg_actor_ref(const_sg_actor_t actor);
82 XBT_PUBLIC void sg_actor_unref(const_sg_actor_t actor);
83 XBT_PUBLIC void* sg_actor_get_data(const_sg_actor_t actor);
84 XBT_PUBLIC void sg_actor_set_data(sg_actor_t actor, void* userdata);
85
86 XBT_PUBLIC sg_exec_t sg_actor_exec_init(double computation_amount);
87 XBT_PUBLIC sg_exec_t sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, double* flops_amount,
88                                                  double* bytes_amount);
89 XBT_PUBLIC sg_exec_t sg_actor_exec_async(double computation_amount);
90 SG_END_DECL
91
92 #endif /* INCLUDE_SIMGRID_ACTOR_H_ */