Topic: Exception 'locking


Author: "Eugene Radchenko" <eugene@qsar.chem.msu.su>
Date: 1996/05/06
Raw View
Hi!
I have got an idea regarding the exception safety. Some people feel that
there will be cases when complete exception safety is
impractical/impossible for performance reasons.
Might we solve this to some extent by introducing the function
  void lockexceptions(bool lock = true);

The idea is: you call it
  lockexceptions(true);
to the effect of saying 'I gonna do some tricky stuff here so do not
disturb please - otherwise all is lost'.
It increments the internal counter. If it is non-zero and exception gets
thrown, program terminates (we can reuse unexpected() or invent third (5th,
counting exit() and abort()) function specifically for the task).
Having completed the tricky things, we call
  lockexceptions(false);
to decrement the counter. [Wrapper class is of course possible]

Benefit is that we get well-defined terminaion instead of undefined
behavior (most probably seemingly unprovoked crash in some other part of
program). Price has something to do with the question of whether the
standard should support (in fact , encourage) not-exception-safe
programming.

      So, what do you think?                  Genie
--
-----------------------------------------------------------------------
Eugene V. Radchenko              Research associate, Computer Chemistry
E-mail: eugene@qsar.chem.msu.su                   Fax: +7-(095)939-0290
Ordinary mail:     Chair of Organic Chemistry, Department of Chemistry,
                         Moscow State University, 119899 Moscow, Russia
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
 I don't think anyone on the C++ standards committee believes that all
 C++ programs should be strictly conforming.
                           Fergus Henderson, moderator of comp.std.c++
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]