I am looking for deadlock free and easy synchronization constructs to provide synchronization for class member functions.
Please consider the following example. Thanks :)
class Integer
{
private:
int x;
public:
Integer () : x(0) {}
~Integer() {}
void increment()
{
/*what is the best way that c++ 14 or c++ 11 provides to enable synchronization here
* something like : "enter_synchronized();", a simple and deadlock free construct.*/
++x;
//end_synchronized()
}
};
Integer i;
void incrementInteger() //This function can be called by multiple threads.
{
i.increment()
}