Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
C++CodeRAD Studio

Learn About Allow Atomics Use In Signal Handlers With C++ For Windows Development In C++Builder

C++11 allows the use of atomics in signal handlers. The atomics operations library was designed to support several different applications:

  • To communicate between threads in cases in which other synchronization mechanisms such as locks are less appropriate.
  • To communicate between processes when other synchronization mechanisms do not support it suitably.
  • To allow for communication with signal handlers.

In the last case, locks are generally not usable since the signal handler may have interrupted a thread holding a lock. Depending on whether the lock is reentrant, an attempt to acquire the lock in the handler would either result in deadlock, or in two logically distinct tasks acquiring the lock at the same time.

When the processing of the abstract machine is interrupted by receipt of a signal, the values of objects which are neither,

  • of type volatile std::sig_atomic_t, nor
  • a lock-free atomic object

are unspecified, and the value of any object not in either of these two categories that is modified by the handler becomes undefined.

The common subset of the C and C++ languages consists of all declarations, definitions, and expressions that may appear in a well formed C++ program and also in a conforming C program. A POF (plain old function) is a function that uses only features from this common subset, and that does not directly or indirectly use any function that is not a POF. All signal handlers shall have C linkage. A POF that could be used as a signal handler in a conforming C program does not produce undefined behavior when used as a signal handler in a C++ program. The behavior of any other function used as a signal handler in a C++ program is implementation-defined.

Head over and check out all of the modern C++ language features available in C++Builder for Windows development.

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Related posts

Measure Heart Rate Using Delphi And C++ Builder With The Power Of ThingConnect IoT Device Component Pack


Create Enterprise-Grade WebSockets Based Apps With Powerful Components For Delphi


Incredibly Powerful Enhanced Terminal And Network Toolkit For Windows Is Built In Delphi

C++CodeRAD Studio

Learn How To Use C++ Explicit Virtual Overrides In Windows Development

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.