SimGrid  3.18
Versatile Simulation of Distributed Systems
simgrid::xbt Namespace Reference

Namespaces

 bits
 

Classes

class  Extendable
 An Extendable is an object that you can extend with external elements. More...
 
class  Extension
 
class  HeapComparator
 Comparator class for using with std::priority_queue or boost::heap. More...
 
class  integer_sequence
 A compile-time sequence of integers (from C++14) More...
 
class  MainFunction
 
class  Parmap
 
class  Path
 
class  Range
 Describes a contiguous inclusive-exclusive [a,b) range of values. More...
 
class  ReplayReader
 
class  Result
 A value or an exception (or nothing) More...
 
class  Result< T & >
 
class  Result< void >
 
class  signal
 
class  signal< R(P...)>
 A signal/slot mechanism. More...
 
class  Task
 
class  Task< R(Args...)>
 Type-erased run-once task. More...
 
class  TaskImpl
 
class  ThrowPoint
 The location of where an exception has been throwed. More...
 
struct  VmMap
 An virtual memory map entry from /proc/$pid/maps. More...
 
class  WithContext
 Internal class used to mixin an exception E with WithContextException. More...
 
class  WithContextException
 A base class for exceptions with context. More...
 

Typedefs

template<class T >
using DynarRange = boost::iterator_range< T * >
 A C++ range from a a dynar. More...
 
typedef std::vector< xbt_backtrace_location_tBacktrace
 A backtrace. More...
 
typedef std::string string
 
template<class T , T N>
using make_integer_sequence = typename simgrid::xbt::bits::make_integer_sequence< T, N >::type
 A compile-time sequence of integers of the form (0,1,2,3,...,N-1) (from C++14) More...
 
template<std::size_t... Ints>
using index_sequence = integer_sequence< std::size_t, Ints... >
 A compile-time sequence of indices (from C++14) More...
 
template<std::size_t N>
using make_index_sequence = make_integer_sequence< std::size_t, N >
 A compile-time sequence of indices of the form (0,1,2,3,...,N-1) (from C++14) More...
 
template<class... T>
using index_sequence_for = make_index_sequence< sizeof...(T)>
 Convert a type parameter pack into a index_sequence (from C++14) More...
 

Functions

template<class ForwardIterator , class ColorFunction >
void three_way_partition (ForwardIterator first, ForwardIterator last, ColorFunction color)
 Sorts the elements of the sequence [first, last) according to their color assuming elements can have only three colors. More...
 
template<class F >
xbt_automaton_propositional_symbol_t add_proposition (xbt_automaton_t a, const char *id, F f)
 Add a proposition to an automaton (the C++ way) More...
 
std::vector< xbt_backtrace_location_tbacktrace ()
 Get the current backtrace. More...
 
std::vector< std::stringresolveBacktrace (xbt_backtrace_location_t const *loc, std::size_t count)
 
template<class T >
DynarRange< T > range (xbt_dynar_t dynar)
 Create an iterator range representing a dynar. More...
 
template<class T >
xbt_dynar_t newDeleteDynar ()
 Dynar of T* which delete its values. More...
 
template<class F >
std::function< void()> wrapMain (F code, std::vector< std::string > args)
 
template<class F >
std::function< void()> wrapMain (F code, int argc, const char *const argv[])
 
template<class F , class Tuple >
constexpr auto apply (F &&f, Tuple &&t) -> decltype(simgrid::xbt::bits::apply(std::forward< F >(f), std::forward< Tuple >(t), simgrid::xbt::make_index_sequence< std::tuple_size< typename std::decay< Tuple >::type >::value >()))
 Call a functional object with the values in the given tuple (from C++17) More...
 
template<class F , class... Args>
auto makeTask (F code, Args... args) -> Task< decltype(code(std::move(args)...))() >
 
template<class R , class F >
auto fulfillPromise (R &promise, F &&code) -> decltype(promise.set_value(code()))
 Execute some code and set a promise or result accordingly. More...
 
template<class P , class F >
auto fulfillPromise (P &promise, F &&code) -> decltype(promise.set_value())
 
template<class P , class F >
void setPromise (P &promise, F &&future)
 Set a promise/result from a future/result. More...
 
void logException (e_xbt_log_priority_t priority, const char *context, std::exception const &exception)
 Display informations about an exception. More...
 
void installExceptionHandler ()
 
std::string string_printf (const char *fmt,...)
 Create a C++ string from a C-style format. More...
 
std::string string_vprintf (const char *fmt, va_list ap)
 Create a C++ string from a C-style format. More...
 
const std::error_category & errno_category () noexcept
 A error_category suitable to be used with errno More...
 
std::error_code errno_code (int errnum)
 Create a error_code from an errno value. More...
 
std::error_code errno_code ()
 Create an error_code from errno (and clear it) More...
 
std::system_error errno_error (int errnum)
 Create a system_error from an errno value. More...
 
std::system_error errno_error (int errnum, const char *what)
 
std::system_error errno_error ()
 Create a system_code from errno (and clear it) More...
 
std::system_error errno_error (const char *what)
 
template<class List , class Elem >
void intrusive_erase (List &list, Elem &elem)
 Erase an element given by reference from a boost::intrusive::list. More...
 
std::unique_ptr< char, void(*)(void *)> demangle (const char *name)
 
static std::string get_binary_path ()
 Find the path of the binary file from the name found in argv. More...
 
static void showBacktrace (std::vector< xbt_backtrace_location_t > &bt)
 
static void handler ()
 
std::vector< VmMapget_memory_map (pid_t pid)
 
static void read_and_trim_line (std::ifstream *fs, std::string *line)
 
static ReplayAction * get_action (char *name)
 
static void handle_action (ReplayAction *action)
 
int replay_runner (int argc, char *argv[])
 function used internally to actually run the replay More...
 

Variables

std::unique_ptr< char, void(*)(void *)> demangle (const char *name)
 Try to demangle a C++ name. More...
 
static std::terminate_handler previous_terminate_handler = nullptr
 
std::ifstream * action_fs = nullptr
 
std::unordered_map< std::string, action_funaction_funs
 

Typedef Documentation

◆ DynarRange

template<class T >
using simgrid::xbt::DynarRange = typedef boost::iterator_range<T*>

A C++ range from a a dynar.

◆ string

typedef std::string simgrid::xbt::string

◆ make_integer_sequence

template<class T , T N>
using simgrid::xbt::make_integer_sequence = typedef typename simgrid::xbt::bits::make_integer_sequence<T,N>::type

A compile-time sequence of integers of the form (0,1,2,3,...,N-1) (from C++14)

◆ index_sequence

template<std::size_t... Ints>
using simgrid::xbt::index_sequence = typedef integer_sequence<std::size_t, Ints...>

A compile-time sequence of indices (from C++14)

◆ make_index_sequence

template<std::size_t N>
using simgrid::xbt::make_index_sequence = typedef make_integer_sequence<std::size_t, N>

A compile-time sequence of indices of the form (0,1,2,3,...,N-1) (from C++14)

◆ index_sequence_for

template<class... T>
using simgrid::xbt::index_sequence_for = typedef make_index_sequence<sizeof...(T)>

Convert a type parameter pack into a index_sequence (from C++14)

Function Documentation

◆ three_way_partition()

template<class ForwardIterator , class ColorFunction >
void simgrid::xbt::three_way_partition ( ForwardIterator  first,
ForwardIterator  last,
ColorFunction  color 
)

Sorts the elements of the sequence [first, last) according to their color assuming elements can have only three colors.

Since there are only three colors, it is linear and much faster than a classical sort. See for example http://en.wikipedia.org/wiki/Dutch_national_flag_problem

Parameters
firstforward iterators to the initial position of the sequence to partition.
lastforward iterators to the final position of the sequence to partition.
colorthe color function that accepts an element in the range as argument, and returns a value of 0, 1, or 2.

At the end of the call, elements with color 0 are at the beginning of the range, elements with color 2 are at the end and elements with color 1 are in the middle.

◆ add_proposition()

template<class F >
xbt_automaton_propositional_symbol_t simgrid::xbt::add_proposition ( xbt_automaton_t  a,
const char *  id,
f 
)

Add a proposition to an automaton (the C++ way)

This API hides all the callback and dynamic allocation hell from the used which can use C++ style functors and lambda expressions.

◆ backtrace()

std::vector< xbt_backtrace_location_t > simgrid::xbt::backtrace ( )

Get the current backtrace.

◆ resolveBacktrace()

std::vector< std::string > simgrid::xbt::resolveBacktrace ( xbt_backtrace_location_t const *  loc,
std::size_t  count 
)

◆ range()

template<class T >
DynarRange<T> simgrid::xbt::range ( xbt_dynar_t  dynar)
inline

Create an iterator range representing a dynar.

C++ range loops for xbt_dynar_t:

for (auto& x : range<double>(some_dynar)) ++x;

◆ newDeleteDynar()

template<class T >
xbt_dynar_t simgrid::xbt::newDeleteDynar ( )
inline

Dynar of T* which delete its values.

◆ wrapMain() [1/2]

template<class F >
std::function<void()> simgrid::xbt::wrapMain ( code,
std::vector< std::string args 
)
inline

◆ wrapMain() [2/2]

template<class F >
std::function<void()> simgrid::xbt::wrapMain ( code,
int  argc,
const char *const  argv[] 
)
inline

◆ apply()

template<class F , class Tuple >
constexpr auto simgrid::xbt::apply ( F &&  f,
Tuple &&  t 
) -> decltype(simgrid::xbt::bits::apply( std::forward<F>(f), std::forward<Tuple>(t), simgrid::xbt::make_index_sequence< std::tuple_size<typename std::decay<Tuple>::type>::value >()))

Call a functional object with the values in the given tuple (from C++17)

int foo(int a, bool b);
auto args = std::make_tuple(1, false);
int res = apply(foo, args);

◆ makeTask()

template<class F , class... Args>
auto simgrid::xbt::makeTask ( code,
Args...  args 
) -> Task< decltype(code(std::move(args)...))() >

◆ fulfillPromise() [1/2]

template<class R , class F >
auto simgrid::xbt::fulfillPromise ( R &  promise,
F &&  code 
) -> decltype(promise.set_value(code()))

Execute some code and set a promise or result accordingly.

Roughly this does:

promise.set_value(code());

but it takes care of exceptions and works with void.

We might need this when working with generic code because the trivial implementation does not work with void (before C++1z).

Parameters
codeWhat we want to do
promiseWhere to want to store the result

◆ fulfillPromise() [2/2]

template<class P , class F >
auto simgrid::xbt::fulfillPromise ( P &  promise,
F &&  code 
) -> decltype(promise.set_value())

◆ setPromise()

template<class P , class F >
void simgrid::xbt::setPromise ( P &  promise,
F &&  future 
)
inline

Set a promise/result from a future/result.

Roughly this does:

promise.set_value(future);

but it takes care of exceptions and works with void.

We might need this when working with generic code because the trivial implementation does not work with void (before C++1z).

Parameters
promiseoutput (a valid future or a result)
futureinput (a ready/waitable future or a valid result)

◆ installExceptionHandler()

void simgrid::xbt::installExceptionHandler ( )

◆ errno_category()

const std::error_category& simgrid::xbt::errno_category ( )
inlinenoexcept

A error_category suitable to be used with errno

It is not clear which error we are supposed to generate when getting a errno:

  • system_error clearly cannot be used for this on Windows;
  • generic_error might not be used for non-standard errno.

Let's just define a function which gives us the correct category.

◆ errno_code() [1/2]

std::error_code simgrid::xbt::errno_code ( int  errnum)
inline

Create a error_code from an errno value.

This is expected to to whatever is right to create a error_code from a given errno value.

◆ errno_code() [2/2]

std::error_code simgrid::xbt::errno_code ( )
inline

Create an error_code from errno (and clear it)

◆ errno_error() [1/4]

std::system_error simgrid::xbt::errno_error ( int  errnum)
inline

Create a system_error from an errno value.

This is expected to to whatever is right to create a system_error from a given errno value.

◆ errno_error() [2/4]

std::system_error simgrid::xbt::errno_error ( int  errnum,
const char *  what 
)
inline

◆ errno_error() [3/4]

std::system_error simgrid::xbt::errno_error ( )
inline

Create a system_code from errno (and clear it)

◆ errno_error() [4/4]

std::system_error simgrid::xbt::errno_error ( const char *  what)
inline

◆ intrusive_erase()

template<class List , class Elem >
void simgrid::xbt::intrusive_erase ( List &  list,
Elem &  elem 
)
inline

Erase an element given by reference from a boost::intrusive::list.

◆ demangle()

std::unique_ptr<char, void(*)(void*)> simgrid::xbt::demangle ( const char *  name)

◆ get_binary_path()

static std::string simgrid::xbt::get_binary_path ( )
static

Find the path of the binary file from the name found in argv.

◆ showBacktrace()

static void simgrid::xbt::showBacktrace ( std::vector< xbt_backtrace_location_t > &  bt)
static

◆ handler()

static void simgrid::xbt::handler ( )
static

◆ get_memory_map()

std::vector< VmMap > simgrid::xbt::get_memory_map ( pid_t  pid)

Currently, xbt_abort() is called but we should much rather die with the specific reason so that it's easier to find out what's going on.

◆ read_and_trim_line()

static void simgrid::xbt::read_and_trim_line ( std::ifstream *  fs,
std::string line 
)
static

◆ get_action()

static ReplayAction* simgrid::xbt::get_action ( char *  name)
static

◆ handle_action()

static void simgrid::xbt::handle_action ( ReplayAction *  action)
static

Variable Documentation

◆ demangle

std::unique_ptr<char, void(*)(void*)> simgrid::xbt::demangle(const char *name)

Try to demangle a C++ name.

Return the origin string if this fails.

◆ previous_terminate_handler

std::terminate_handler simgrid::xbt::previous_terminate_handler = nullptr
static

◆ action_fs

std::ifstream* simgrid::xbt::action_fs = nullptr

◆ action_funs

std::unordered_map<std::string, action_fun> simgrid::xbt::action_funs