1 /* Copyright (c) 2004-2021. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_TYPES_H
7 #define SIMGRID_TYPES_H
13 #include <boost/intrusive_ptr.hpp>
20 /** Smart pointer to a simgrid::s4u::Activity */
21 using ActivityPtr = boost::intrusive_ptr<Activity>;
22 XBT_PUBLIC void intrusive_ptr_release(const Activity* actor);
23 XBT_PUBLIC void intrusive_ptr_add_ref(const Activity* actor);
26 /** Smart pointer to a simgrid::s4u::Actor */
27 using ActorPtr = boost::intrusive_ptr<Actor>;
28 XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
29 XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
32 /** Smart pointer to a simgrid::s4u::Barrier */
33 using BarrierPtr = boost::intrusive_ptr<Barrier>;
34 XBT_PUBLIC void intrusive_ptr_release(Barrier* m);
35 XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* m);
38 /** Smart pointer to a simgrid::s4u::Comm */
39 using CommPtr = boost::intrusive_ptr<Comm>;
40 XBT_PUBLIC void intrusive_ptr_release(Comm* c);
41 XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
43 class ConditionVariable;
45 * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
48 using ConditionVariablePtr = boost::intrusive_ptr<ConditionVariable>;
49 XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
50 XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
55 /** Smart pointer to a simgrid::s4u::Exec */
56 using ExecPtr = boost::intrusive_ptr<Exec>;
57 XBT_PUBLIC void intrusive_ptr_release(Exec* e);
58 XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
63 /** Smart pointer to a simgrid::s4u::Io */
64 using IoPtr = boost::intrusive_ptr<Io>;
65 XBT_PUBLIC void intrusive_ptr_release(Io* i);
66 XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
73 XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
74 XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
77 * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
80 using MutexPtr = boost::intrusive_ptr<Mutex>;
87 /** Smart pointer to a simgrid::s4u::Semaphore */
88 using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
89 XBT_PUBLIC void intrusive_ptr_release(Semaphore* m);
90 XBT_PUBLIC void intrusive_ptr_add_ref(Semaphore* m);
96 template <class T> class Flag;
103 using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
105 // What's executed as an actor code:
106 using ActorCode = std::function<void()>;
107 // Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
108 using ActorCodeFactory = std::function<ActorCode(std::vector<std::string> args)>;
114 using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
115 XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
116 XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
118 class ConditionVariableImpl;
121 using CommImplPtr = boost::intrusive_ptr<CommImpl>;
123 using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
125 using IoImplPtr = boost::intrusive_ptr<IoImpl>;
127 using MutexImplPtr = boost::intrusive_ptr<MutexImpl>;
129 using RawImplPtr = boost::intrusive_ptr<RawImpl>;
131 using SemaphoreImplPtr = boost::intrusive_ptr<SemaphoreImpl>;
133 using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
139 class ContextFactory;
140 } // namespace context
145 class ConstraintLight;
161 class ClusterCreationArgs;
162 class LinkCreationArgs;
165 class RouteCreationArgs;
171 } // namespace profile
172 } // namespace kernel
182 class CommunicationDeterminismChecker;
183 class SimcallInspector;
187 class VirtualMachineImpl;
189 } // namespace simgrid
191 using s4u_Actor = simgrid::s4u::Actor;
192 using s4u_Barrier = simgrid::s4u::Barrier;
193 using s4u_Comm = simgrid::s4u::Comm;
194 using s4u_Exec = simgrid::s4u::Exec;
195 using s4u_Host = simgrid::s4u::Host;
196 using s4u_Link = simgrid::s4u::Link;
197 using s4u_File = simgrid::s4u::File;
198 using s4u_ConditionVariable = simgrid::s4u::ConditionVariable;
199 using s4u_Mailbox = simgrid::s4u::Mailbox;
200 using s4u_Mutex = simgrid::s4u::Mutex;
201 using s4u_Semaphore = simgrid::s4u::Semaphore;
202 using s4u_Disk = simgrid::s4u::Disk;
203 using s4u_NetZone = simgrid::s4u::NetZone;
204 using s4u_VM = simgrid::s4u::VirtualMachine;
206 using smx_timer_t = simgrid::simix::Timer*;
207 using smx_actor_t = simgrid::kernel::actor::ActorImpl*;
208 using smx_activity_t = simgrid::kernel::activity::ActivityImpl*;
209 using smx_cond_t = simgrid::kernel::activity::ConditionVariableImpl*;
210 using smx_mailbox_t = simgrid::kernel::activity::MailboxImpl*;
211 using smx_mutex_t = simgrid::kernel::activity::MutexImpl*;
212 using smx_sem_t = simgrid::kernel::activity::SemaphoreImpl*;
213 using e_smx_state_t XBT_ATTRIB_DEPRECATED_v330("Please use kernel::activity::State") = simgrid::kernel::activity::State;
216 typedef struct s4u_Actor s4u_Actor;
217 typedef struct s4u_Barrier s4u_Barrier;
218 typedef struct s4u_Comm s4u_Comm;
219 typedef struct s4u_Exec s4u_Exec;
220 typedef struct s4u_Host s4u_Host;
221 typedef struct s4u_Link s4u_Link;
222 typedef struct s4u_File s4u_File;
223 typedef struct s4u_ConditionVariable s4u_ConditionVariable;
224 typedef struct s4u_Mailbox s4u_Mailbox;
225 typedef struct s4u_Mutex s4u_Mutex;
226 typedef struct s4u_Semaphore s4u_Semaphore;
227 typedef struct s4u_Disk s4u_Disk;
228 typedef struct s4u_NetZone s4u_NetZone;
229 typedef struct s4u_VM s4u_VM;
230 XBT_ATTRIB_DEPRECATED_v330("Please stop using this type alias") typedef enum kernel_activity_state e_smx_state_t;
232 typedef struct s_smx_timer* smx_timer_t;
233 typedef struct s_smx_actor* smx_actor_t;
234 typedef struct s_smx_activity* smx_activity_t;
235 typedef struct s_smx_cond_t* smx_cond_t;
236 typedef struct s_smx_mailbox* smx_mailbox_t;
237 typedef struct s_smx_mutex* smx_mutex_t;
238 typedef struct s_smx_sem* smx_sem_t;
242 /** Pointer to a SimGrid barrier object */
243 typedef s4u_Barrier* sg_bar_t;
244 /** Constant pointer to a SimGrid barrier object */
245 typedef const s4u_Barrier* const_sg_bar_t;
246 typedef s4u_Comm* sg_comm_t;
247 typedef const s4u_Comm* const_sg_comm_t;
248 typedef s4u_Exec* sg_exec_t;
249 typedef const s4u_Exec* const_sg_exec_t;
250 typedef s4u_ConditionVariable* sg_cond_t;
251 typedef const s4u_ConditionVariable* const_sg_cond_t;
252 typedef s4u_Mailbox* sg_mailbox_t;
253 typedef const s4u_Mailbox* const_sg_mailbox_t;
254 typedef s4u_Mutex* sg_mutex_t;
255 typedef const s4u_Mutex* const_sg_mutex_t;
256 typedef s4u_Semaphore* sg_sem_t;
257 typedef const s4u_Semaphore* const_sg_sem_t;
258 typedef s4u_NetZone* sg_netzone_t;
259 typedef const s4u_NetZone* const_sg_netzone_t;
260 typedef s4u_Host* sg_host_t;
261 typedef const s4u_Host* const_sg_host_t;
262 typedef s4u_Link* sg_link_t;
263 typedef const s4u_Link* const_sg_link_t;
264 typedef s4u_Disk* sg_disk_t;
265 typedef const s4u_Disk* const_sg_disk_t;
266 /** Pointer to a SimGrid file object */
267 typedef s4u_File* sg_file_t;
268 /** Constant pointer to a SimGrid file object */
269 typedef const s4u_File* const_sg_file_t;
270 typedef s4u_VM* sg_vm_t;
271 typedef const s4u_VM* const_sg_vm_t;
272 typedef s4u_Actor* sg_actor_t;
273 typedef const s4u_Actor* const_sg_actor_t;
275 typedef struct s_smx_simcall* smx_simcall_t;
277 /** @ingroup m_datatypes_management_details
278 * @brief Type for any simgrid size
280 typedef unsigned long long sg_size_t;
282 /** @ingroup m_datatypes_management_details
283 * @brief Type for any simgrid offset
285 typedef long long sg_offset_t;
287 /** Actor's ID, just like the classical processes' have PID in UNIX */
300 #endif /* SIMGRID_TYPES_H */