Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Install a tesh.py dependency on travis (at least, try to)
[simgrid.git] / doc / doxygen / module-s4u.doc
1 /**
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++. 
4
5 The S4U API is currently under heavy work, but will eventually
6 deprecate the MSG and SimDag APIs. Everything that you can do in
7 SimGrid will be possible in S4U. 
8
9 @warning <b>S4U is not ready for public use yet</b>. You should not go
10          that path unless you know what you are doing.  If unsure,
11          proceed to @ref MSG_API instead.
12
13 Unsurprisingly, the S4U interface matches the concepts presented in 
14 @ref starting_components "the introduction". You should read this page
15 first, to not get lost in the amount of classes provided here. Or you
16 could jump to the \ref s4u_examples directly if you prefer.
17
18 @section s4u_raii Memory Management of S4U objects
19
20 For sake of simplicity, we use
21 [RAII](https://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization)
22 everywhere in S4U. This is an idiom where resources are automatically
23 managed through the context. Provided that you never manipulate
24 objects of type Foo directly but always FooPtr references (which are
25 [boost::intrusive_ptr](http://www.boost.org/doc/libs/1_61_0/libs/smart_ptr/intrusive_ptr.html)<Foo>),
26 you will never have to explicitely release the resource that you use
27 nor to free the memory of unused objects.
28
29 Here is a little example:
30
31 @code{cpp}
32 void myFunc() 
33 {
34   simgrid::s4u::MutexPtr mutex = simgrid::s4u::Mutex::createMutex(); // Too bad we cannot use `new` here
35
36   mutex->lock();   // use the mutex as a simple reference
37   //  bla bla
38   mutex->unlock(); 
39   
40 } // The mutex will get automatically freed because the only existing reference gets out of scope
41 @endcode
42 */