1 /* Copyright (c) 2004-2023. 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* act);
23 XBT_PUBLIC void intrusive_ptr_add_ref(const Activity* act);
26 /** Smart pointer to a simgrid::s4u::Activity */
27 using ActivitySetPtr = boost::intrusive_ptr<ActivitySet>;
28 XBT_PUBLIC void intrusive_ptr_release(const ActivitySet* as);
29 XBT_PUBLIC void intrusive_ptr_add_ref(const ActivitySet* as);
32 /** Smart pointer to a simgrid::s4u::Actor */
33 using ActorPtr = boost::intrusive_ptr<Actor>;
34 XBT_PUBLIC void intrusive_ptr_release(const Actor* actor);
35 XBT_PUBLIC void intrusive_ptr_add_ref(const Actor* actor);
38 /** Smart pointer to a simgrid::s4u::Barrier */
39 using BarrierPtr = boost::intrusive_ptr<Barrier>;
40 XBT_PUBLIC void intrusive_ptr_release(Barrier* b);
41 XBT_PUBLIC void intrusive_ptr_add_ref(Barrier* b);
44 /** Smart pointer to a simgrid::s4u::Comm */
45 using CommPtr = boost::intrusive_ptr<Comm>;
46 XBT_PUBLIC void intrusive_ptr_release(Comm* c);
47 XBT_PUBLIC void intrusive_ptr_add_ref(Comm* c);
49 class ConditionVariable;
51 * Smart pointer to a :cpp:type:`simgrid::s4u::ConditionVariable`
54 using ConditionVariablePtr = boost::intrusive_ptr<ConditionVariable>;
55 XBT_PUBLIC void intrusive_ptr_release(const ConditionVariable* c);
56 XBT_PUBLIC void intrusive_ptr_add_ref(const ConditionVariable* c);
61 /** Smart pointer to a simgrid::s4u::Exec */
62 using ExecPtr = boost::intrusive_ptr<Exec>;
63 XBT_PUBLIC void intrusive_ptr_release(Exec* e);
64 XBT_PUBLIC void intrusive_ptr_add_ref(Exec* e);
69 /** Smart pointer to a simgrid::s4u::Io */
70 using IoPtr = boost::intrusive_ptr<Io>;
71 XBT_PUBLIC void intrusive_ptr_release(Io* i);
72 XBT_PUBLIC void intrusive_ptr_add_ref(Io* i);
75 class SplitDuplexLink;
80 /** Smart pointer to a simgrid::s4u::Mess */
81 using MessPtr = boost::intrusive_ptr<Mess>;
82 XBT_PUBLIC void intrusive_ptr_release(Mess* c);
83 XBT_PUBLIC void intrusive_ptr_add_ref(Mess* c);
88 XBT_PUBLIC void intrusive_ptr_release(const Mutex* m);
89 XBT_PUBLIC void intrusive_ptr_add_ref(const Mutex* m);
92 * Smart pointer to a :cpp:type:`simgrid::s4u::Mutex`
95 using MutexPtr = boost::intrusive_ptr<Mutex>;
102 /** Smart pointer to a simgrid::s4u::Semaphore */
103 using SemaphorePtr = boost::intrusive_ptr<Semaphore>;
104 XBT_PUBLIC void intrusive_ptr_release(const Semaphore* m);
105 XBT_PUBLIC void intrusive_ptr_add_ref(const Semaphore* m);
110 /** Smart pointer to a simgrid::s4u::Task */
111 using TaskPtr = boost::intrusive_ptr<Task>;
112 XBT_PUBLIC void intrusive_ptr_release(Task* o);
113 XBT_PUBLIC void intrusive_ptr_add_ref(Task* o);
115 using ExecTaskPtr = boost::intrusive_ptr<ExecTask>;
117 using CommTaskPtr = boost::intrusive_ptr<CommTask>;
119 using IoTaskPtr = boost::intrusive_ptr<IoTask>;
122 * @brief Callback to dynamically change the resource's capacity
124 * Allows user to change resource's capacity depending on the number of concurrent activities
125 * running on the resource at a given instant
127 using NonLinearResourceCb = std::function<double(double capacity, int n_activities)>;
131 template <class T> class Flag;
138 using ActorImplPtr = boost::intrusive_ptr<ActorImpl>;
140 // What's executed as an actor code:
141 using ActorCode = std::function<void()>;
142 // Create an ActorCode from the parameters parsed in the XML file (or elsewhere)
143 using ActorCodeFactory = std::function<ActorCode(std::vector<std::string> args)>;
146 class SimcallObserver;
148 class ConditionVariableObserver;
149 class ObjectAccessSimcallObserver;
150 class ObjectAccessSimcallItem;
156 using ActivityImplPtr = boost::intrusive_ptr<ActivityImpl>;
157 XBT_PUBLIC void intrusive_ptr_add_ref(ActivityImpl* activity);
158 XBT_PUBLIC void intrusive_ptr_release(ActivityImpl* activity);
161 using BarrierImplPtr = boost::intrusive_ptr<BarrierImpl>;
162 XBT_PUBLIC void intrusive_ptr_add_ref(BarrierImpl* cond);
163 XBT_PUBLIC void intrusive_ptr_release(BarrierImpl* cond);
164 class BarrierAcquisitionImpl;
165 using BarrierAcquisitionImplPtr = boost::intrusive_ptr<BarrierAcquisitionImpl>;
167 class ConditionVariableImpl;
168 using ConditionVariableImplPtr = boost::intrusive_ptr<ConditionVariableImpl>;
169 XBT_PUBLIC void intrusive_ptr_add_ref(ConditionVariableImpl* cond);
170 XBT_PUBLIC void intrusive_ptr_release(ConditionVariableImpl* cond);
171 class ConditionVariableAcquisitionImpl;
172 using ConditionVariableAcquisitionImplPtr = boost::intrusive_ptr<ConditionVariableAcquisitionImpl>;
175 using CommImplPtr = boost::intrusive_ptr<CommImpl>;
177 using ExecImplPtr = boost::intrusive_ptr<ExecImpl>;
179 using IoImplPtr = boost::intrusive_ptr<IoImpl>;
181 using MessImplPtr = boost::intrusive_ptr<MessImpl>;
183 using MutexImplPtr = boost::intrusive_ptr<MutexImpl>;
184 class MutexAcquisitionImpl;
185 using MutexAcquisitionImplPtr = boost::intrusive_ptr<MutexAcquisitionImpl>;
186 XBT_PUBLIC void intrusive_ptr_add_ref(MutexImpl* mutex);
187 XBT_PUBLIC void intrusive_ptr_release(MutexImpl* mutex);
189 using SynchroImplPtr = boost::intrusive_ptr<SynchroImpl>;
191 using SemaphoreImplPtr = boost::intrusive_ptr<SemaphoreImpl>;
192 class SemAcquisitionImpl;
193 using SemAcquisitionImplPtr = boost::intrusive_ptr<SemAcquisitionImpl>;
194 XBT_PUBLIC void intrusive_ptr_add_ref(SemaphoreImpl* sem);
195 XBT_PUBLIC void intrusive_ptr_release(SemaphoreImpl* sem);
197 using SleepImplPtr = boost::intrusive_ptr<SleepImpl>;
200 class MessageQueueImpl;
204 class ContextFactory;
205 } // namespace context
210 class ConstraintLight;
224 class StandardLinkImpl;
225 class SplitDuplexLinkImpl;
228 using DiskImplPtr = boost::intrusive_ptr<DiskImpl>;
230 class VirtualMachineImpl;
244 } // namespace profile
245 } // namespace kernel
250 } // namespace simgrid
252 using s4u_Actor = simgrid::s4u::Actor;
253 using s4u_Activity = simgrid::s4u::Activity;
254 using s4u_ActivitySet = simgrid::s4u::ActivitySet;
255 using s4u_Barrier = simgrid::s4u::Barrier;
256 using s4u_Comm = simgrid::s4u::Comm;
257 using s4u_Exec = simgrid::s4u::Exec;
258 using s4u_Host = simgrid::s4u::Host;
259 using s4u_Link = simgrid::s4u::Link;
260 using s4u_File = simgrid::s4u::File;
261 using s4u_ConditionVariable = simgrid::s4u::ConditionVariable;
262 using s4u_Mailbox = simgrid::s4u::Mailbox;
263 using s4u_MessageQueue = simgrid::s4u::MessageQueue;
264 using s4u_Mutex = simgrid::s4u::Mutex;
265 using s4u_Semaphore = simgrid::s4u::Semaphore;
266 using s4u_Disk = simgrid::s4u::Disk;
267 using s4u_NetZone = simgrid::s4u::NetZone;
268 using s4u_VM = simgrid::s4u::VirtualMachine;
270 using smx_activity_t = simgrid::kernel::activity::ActivityImpl*;
273 typedef struct s4u_Actor s4u_Actor;
274 typedef struct s4u_Activity s4u_Activity;
275 typedef struct s4u_ActivitySet s4u_ActivitySet;
276 typedef struct s4u_Barrier s4u_Barrier;
277 typedef struct s4u_Comm s4u_Comm;
278 typedef struct s4u_Exec s4u_Exec;
279 typedef struct s4u_Host s4u_Host;
280 typedef struct s4u_Link s4u_Link;
281 typedef struct s4u_File s4u_File;
282 typedef struct s4u_ConditionVariable s4u_ConditionVariable;
283 typedef struct s4u_Mailbox s4u_Mailbox;
284 typedef struct s4u_MessageQueue s4u_MessageQueue;
285 typedef struct s4u_Mutex s4u_Mutex;
286 typedef struct s4u_Semaphore s4u_Semaphore;
287 typedef struct s4u_Disk s4u_Disk;
288 typedef struct s4u_NetZone s4u_NetZone;
289 typedef struct s4u_VM s4u_VM;
291 typedef struct s_smx_activity* smx_activity_t;
295 /** Pointer to a SimGrid barrier object */
296 typedef s4u_Barrier* sg_bar_t;
297 typedef s4u_Comm* sg_comm_t;
298 typedef s4u_Exec* sg_exec_t;
299 typedef const s4u_Exec* const_sg_exec_t;
300 typedef s4u_ConditionVariable* sg_cond_t;
301 typedef const s4u_ConditionVariable* const_sg_cond_t;
302 typedef s4u_Mailbox* sg_mailbox_t;
303 typedef const s4u_Mailbox* const_sg_mailbox_t;
304 typedef s4u_MessageQueue* sg_messagequeue_t;
305 typedef const s4u_MessageQueue* const_sg_messagequeue_t;
306 typedef s4u_Mutex* sg_mutex_t;
307 typedef const s4u_Mutex* const_sg_mutex_t;
308 typedef s4u_Semaphore* sg_sem_t;
309 typedef const s4u_Semaphore* const_sg_sem_t;
310 typedef s4u_NetZone* sg_netzone_t;
311 typedef const s4u_NetZone* const_sg_netzone_t;
312 typedef s4u_Host* sg_host_t;
313 typedef const s4u_Host* const_sg_host_t;
314 typedef s4u_Link* sg_link_t;
315 typedef const s4u_Link* const_sg_link_t;
316 typedef s4u_Disk* sg_disk_t;
317 typedef const s4u_Disk* const_sg_disk_t;
318 /** Pointer to a SimGrid file object @ingroup plugin_filesystem */
319 typedef s4u_File* sg_file_t;
320 /** Constant pointer to a SimGrid file object @ingroup plugin_filesystem */
321 typedef const s4u_File* const_sg_file_t;
322 typedef s4u_VM* sg_vm_t;
323 typedef const s4u_VM* const_sg_vm_t;
324 /** Pointer to an actor object */
325 typedef s4u_Actor* sg_actor_t;
326 /** Pointer to a constant actor object */
327 typedef const s4u_Actor* const_sg_actor_t;
329 /** Pointer to an activity object */
330 typedef s4u_Activity* sg_activity_t;
331 /** Pointer to a constant activity object */
332 typedef const s4u_Activity* const_sg_activity_t;
334 /** Pointer to an activity set object */
335 typedef s4u_ActivitySet* sg_activity_set_t;
336 /** Pointer to a constant activity set object */
337 typedef const s4u_ActivitySet* const_sg_activity_set_t;
339 /** @ingroup m_datatypes_management_details
340 * @brief Type for any SimGrid size
342 typedef unsigned long long sg_size_t;
344 /** @ingroup m_datatypes_management_details
345 * @brief Type for any SimGrid offset
347 typedef long long sg_offset_t;
349 /** Actor's ID, just like the classical processes' have PID in UNIX */
353 SG_OK /** Code returned when no problem occured */,
354 SG_ERROR_CANCELED /** Code returned when something got canceled before completion */,
355 SG_ERROR_TIMEOUT /** Code returned when timeout elapsed */,
356 SG_ERROR_HOST /** Code returned when a host fails */,
357 SG_ERROR_NETWORK /** Code returned when a communication fails because of the network or because of the remote host */,
358 SG_ERROR_STORAGE /** Code returned when a storage fails */,
359 SG_ERROR_VM /** Code returned when a VM fails */
362 XBT_PUBLIC int SMPI_is_inited();
364 #endif /* SIMGRID_TYPES_H */