2 @defgroup s4u_api S4U: Next generation SimGrid API
3 @brief Future core API, mixing the full power of SimGrid to the power of C++.
5 The S4U API is near from its final state. Everything that you can do in
6 SimGrid should be possible in S4U and the missing pieces are seen as
9 @warning <b>S4U is still evolving: v3.18 is a beta release</b>. You
10 are really welcome to test it, but this API may change
11 between releases. This is however the way to go if you want
12 to create a new long-term project. If you want to play safe,
13 proceed to deprecated @ref MSG_API instead.
15 Unsurprisingly, the S4U interface matches the concepts presented in
16 @ref starting_components "the introduction". You should read this page
17 first, to not get lost in the amount of classes provided here. Or you
18 could jump to the \ref s4u_examples directly if you prefer.
20 @section s4u_raii Memory Management of S4U objects
22 For sake of simplicity, we use
23 [RAII](https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization)
24 everywhere in S4U. This is an idiom where resources are automatically
25 managed through the context. Provided that you never manipulate
26 objects of type Foo directly but always FooPtr references (which are
27 [boost::intrusive_ptr](http://www.boost.org/doc/libs/1_61_0/libs/smart_ptr/intrusive_ptr.html)<Foo>),
28 you will never have to explicitely release the resource that you use
29 nor to free the memory of unused objects.
31 Here is a little example:
36 simgrid::s4u::MutexPtr mutex = simgrid::s4u::Mutex::createMutex(); // Too bad we cannot use `new` here
38 mutex->lock(); // use the mutex as a simple reference
42 } // The mutex will get automatically freed because the only existing reference gets out of scope