HP aC++/HP C A.06.28 Programmer's Guide Integrity servers (769150-001, March 2014)

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 multi-threaded applications. The following HP aC++
libraries are thread-safe with the limitations cited below:
Rogue Wave Standard C++ Library 2.2.1
For both 32-bit and 64-bit libraries:
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 32-bit and 64-bit libraries:
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