My question is about atomic transactions.
int f()
{
static int i = 0;
atomic_noexcept {
// other operations that may fail and throw
++i;
return i;
}
}
int caller(){
unsigned k;
try{
k = f();
}
catch(...){
// retry here? What if that fails again and the program must keep running?
k = f();
}
}
or should we do that this way instead?
int recursive_caller(){
unsigned retry_limit = 15;
unsigned k;
while(retry_limit--){
try{
k = f();
return k;
}
catch(...){
}
}
//handle that failure situation with an exception or else
}
As for atomic_commit, how can it commit if there is an exception laying around?
An example and clarifications would be welcome.
Thanks