A::A() try
: _member(fx())
{
cout << _member << ‘\n’;
}
catch (runtime_error& r) { cout <<r.what() << ‘\n’;
}
Note that the function try block ensures the exception thrown from the member initializer is caught within the constructor.
Debugging Exception Handling
The HP WDB Debugger supports C++ exception handling. For more information refer to HP WDB documentation at http://www.hp.com/go/wdb.
Performance Considerations
HP aC++ exception handling has no significant performance impact at compile time or runtime.
Using Threads
The HP aC++ runtime environment supports
Rogue Wave Standard C++ Library 2.2.1
For both
•libstd_v2.so and libstd_v2.a
•libCsup.so and libCsup.a
•libCsup11.so — ISO C++11 standard compliant
Rogue Wave Standard C++ Library 1.2.1 and Tools.h++ 7.0.6
For both
•libstd.so and libstd.a
•librwtool.so and librwtool.a
•libCsup.so and libCsup.a
•libCsup11.so — ISO C++11 standard compliant
•libstream.so and libstream.a
Using Locks
To guarantee that your I/O results from one thread are not intermingled with I/O results from other threads, you must protect your I/O statements with locks. For example:
//create a mutex and initialize it pthread_mutex_t the_mutex;
#ifdef _PTHREADS_DRAFT4 | // | for | user threads |
pthread_mutex_init(&the_mutex, | pthread_mutexattr_default); | ||
#else | // | for | kernel threads |
pthread_mutex_init(&the_mutex, | (pthread_mutexattr_t *)NULL); | ||
#endif |
|
|
|
pthread_mutex_lock(&the_mutex); cout << “something” ... ; pthread_mutex_unlock(&the_mutex);
Using Threads 163