Mercurial > octave
annotate liboctave/util/unwind-prot.h @ 22402:4caa7b28d183
maint: Style check C++ code in liboctave/
* Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc,
Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc,
Array-util.h, Array-voidp.cc, Array.cc, Array.h, CColVector.cc, CColVector.h,
CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h,
CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc,
DiagArray2.h, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc,
MArray-s.cc, MArray.cc, MArray.h, MDiagArray2.cc, MDiagArray2.h, MSparse-C.cc,
MSparse-d.cc, MSparse.cc, MSparse.h, Matrix.h, MatrixType.cc, MatrixType.h,
PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-C.cc, Sparse-b.cc,
Sparse-d.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc,
boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.cc, chMatrix.h,
chNDArray.cc, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc,
dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc,
dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h,
fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc,
fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h,
fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc,
fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc,
idx-vector.h, int16NDArray.cc, int16NDArray.h, int32NDArray.cc, int32NDArray.h,
int64NDArray.cc, int64NDArray.h, int8NDArray.cc, int8NDArray.h, intNDArray.cc,
intNDArray.h, uint16NDArray.cc, uint16NDArray.h, uint32NDArray.cc,
uint32NDArray.h, uint64NDArray.h, uint8NDArray.h, blaswrap.c, cquit.c,
f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, lo-error.h, quit.cc, quit.h,
liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h,
DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.cc, DASPK.h, DASRT.cc, DASRT.h,
DASSL.cc, DASSL.h, DET.h, EIG.cc, EIG.h, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h,
ODES.cc, ODES.h, ODESFunc.h, Quad.cc, Quad.h, aepbalance.cc, aepbalance.h,
base-dae.h, base-de.h, base-min.h, bsxfun-decl.h, bsxfun-defs.cc, bsxfun.h,
chol.cc, chol.h, eigs-base.cc, eigs-base.h, fEIG.cc, fEIG.h, gepbalance.cc,
gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-amos-proto.h,
lo-arpack-proto.h, lo-blas-proto.h, lo-fftpack-proto.h, lo-lapack-proto.h,
lo-mappers.cc, lo-mappers.h, lo-qrupdate-proto.h, lo-ranlib-proto.h,
lo-slatec-proto.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc,
oct-fftw.cc, oct-fftw.h, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc,
oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h,
randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h,
sparse-chol.cc, sparse-chol.h, sparse-dmsolve.cc, sparse-dmsolve.h,
sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h,
Sparse-diag-op-defs.h, Sparse-op-decls.h, Sparse-op-defs.h,
Sparse-perm-op-defs.h, mx-base.h, mx-defs.h, mx-ext.h, mx-inlines.cc,
mx-op-decl.h, mx-op-defs.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h,
file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h,
mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h,
oct-passwd.cc, oct-passwd.h, oct-syscalls.cc, oct-time.cc, oct-time.h,
oct-uname.cc, oct-uname.h, action-container.h, base-list.h, byte-swap.h,
caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, data-conv.cc,
data-conv.h, f2c-main.c, functor.h, glob-match.cc, glob-match.h, kpse.cc,
kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-array-gripes.cc,
lo-array-gripes.h, lo-cutils.c, lo-cutils.h, lo-hash.cc, lo-hash.h, lo-ieee.cc,
lo-ieee.h, lo-macros.h, lo-math.h, lo-regexp.cc, lo-regexp.h, lo-traits.h,
lo-utils.cc, lo-utils.h, oct-alloc.h, oct-base64.cc, oct-binmap.h, oct-cmplx.h,
oct-glob.cc, oct-glob.h, oct-inttypes-fwd.h, oct-inttypes.cc, oct-inttypes.h,
oct-locbuf.cc, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-rl-edit.c,
oct-rl-edit.h, oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-shlib.h,
oct-sort.cc, oct-sort.h, oct-sparse.h, oct-string.cc, oct-string.h,
pathsearch.cc, pathsearch.h, singleton-cleanup.cc, singleton-cleanup.h,
sparse-sort.cc, sparse-sort.h, sparse-util.cc, sparse-util.h, str-vec.cc,
str-vec.h, sun-utils.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc,
url-transfer.h, areadlink-wrapper.c, areadlink-wrapper.h,
async-system-wrapper.c, async-system-wrapper.h, base64-wrappers.c,
base64-wrappers.h, canonicalize-file-name-wrapper.c,
canonicalize-file-name-wrapper.h, dirent-wrappers.c, dirent-wrappers.h,
fcntl-wrappers.c, fcntl-wrappers.h, filepos-wrappers.c, filepos-wrappers.h,
fpucw-wrappers.c, fpucw-wrappers.h, gen-tempname-wrapper.c,
gen-tempname-wrapper.h, getopt-wrapper.c, glob-wrappers.c, hash-wrappers.c,
hash-wrappers.h, math-wrappers.c, math-wrappers.h, mkostemp-wrapper.c,
mkostemp-wrapper.h, nanosleep-wrapper.c, nanosleep-wrapper.h, nproc-wrapper.c,
nproc-wrapper.h, octave-popen2.c, octave-popen2.h, putenv-wrapper.c,
putenv-wrapper.h, set-program-name-wrapper.c, set-program-name-wrapper.h,
signal-wrappers.c, signal-wrappers.h, stat-wrappers.c, stat-wrappers.h,
strdup-wrapper.c, strdup-wrapper.h, strftime-wrapper.c, strftime-wrapper.h,
strmode-wrapper.c, strmode-wrapper.h, strptime-wrapper.c, strptime-wrapper.h,
time-wrappers.c, time-wrappers.h, tmpfile-wrapper.c, tmpfile-wrapper.h,
uname-wrapper.c, uname-wrapper.h, unistd-wrappers.c, unistd-wrappers.h,
unsetenv-wrapper.c, unsetenv-wrapper.h, vasprintf-wrapper.c,
vasprintf-wrapper.h, wait-for-input.c, wait-for-input.h, wait-wrappers.c,
wait-wrappers.h:
Wrap long lines < 80 characters. Update incorrect indentation.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 29 Aug 2016 11:09:25 -0700 |
parents | bac0d6f07a3e |
children | 3a2b891d0b33 e9a0469dedd9 |
rev | line source |
---|---|
1 | 1 /* |
2 | |
22323
bac0d6f07a3e
maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents:
21752
diff
changeset
|
3 Copyright (C) 1993-2016 John W. Eaton |
11523 | 4 Copyright (C) 2009-2010 VZLU Prague |
1 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1 | 21 |
22 */ | |
23 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
20545
diff
changeset
|
24 #if ! defined (octave_unwind_prot_h) |
383 | 25 #define octave_unwind_prot_h 1 |
1 | 26 |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21141
diff
changeset
|
27 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21141
diff
changeset
|
28 |
17552
d07d59cc8775
move unwind-protect to liboctave
John W. Eaton <jwe@octave.org>
parents:
16892
diff
changeset
|
29 #include <cstddef> |
d07d59cc8775
move unwind-protect to liboctave
John W. Eaton <jwe@octave.org>
parents:
16892
diff
changeset
|
30 |
15396 | 31 #include <stack> |
9394
b3ab22ee8544
further improve unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
9384
diff
changeset
|
32 #include <memory> |
240 | 33 |
15396 | 34 #include "action-container.h" |
35 | |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
36 namespace octave |
2985 | 37 { |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
38 class |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
39 OCTAVE_API |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
40 unwind_protect : public action_container |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
41 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
42 public: |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
43 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
44 unwind_protect (void) : lifo () { } |
2985 | 45 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
46 // Destructor should not raise an exception, so all actions |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
47 // registered should be exception-safe. If you're not sure, see |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
48 // unwind_protect_safe. |
9394
b3ab22ee8544
further improve unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
9384
diff
changeset
|
49 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
50 ~unwind_protect (void) { run (); } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
51 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
52 virtual void add (elem *new_elem) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
53 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
54 lifo.push (new_elem); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
55 } |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9394
diff
changeset
|
56 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
57 OCTAVE_DEPRECATED ("use 'add (new fcn_arg_elem<void *> (fcn, ptr))' instead") |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
58 void add (void (*fcn) (void *), void *ptr = 0) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
59 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
60 add (new fcn_arg_elem<void *> (fcn, ptr)); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
61 } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
62 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
63 operator bool (void) const { return ! empty (); } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
64 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
65 OCTAVE_DEPRECATED ("use 'run_first' instead") |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
66 void run_top (void) { run_first (); } |
10781
f7584d0ba5d3
allow unwind_protect register actions with const T& args
Jaroslav Hajek <highegg@gmail.com>
parents:
10343
diff
changeset
|
67 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
68 void run_first (void) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
69 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
70 if (! empty ()) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
71 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
72 // No leak on exception! |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
73 std::unique_ptr<elem> ptr (lifo.top ()); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
74 lifo.pop (); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
75 ptr->run (); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
76 } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
77 } |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
78 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
79 OCTAVE_DEPRECATED ("use 'run' instead") |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
80 void run_top (int num) { run (num); } |
12122
f4689107dd8c
Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
11586
diff
changeset
|
81 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
82 OCTAVE_DEPRECATED ("use 'discard_first' instead") |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
83 void discard_top (void) { discard_first (); } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
84 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
85 void discard_first (void) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
86 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
87 if (! empty ()) |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
88 { |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
89 elem *ptr = lifo.top (); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
90 lifo.pop (); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
91 delete ptr; |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
92 } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
93 } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
94 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
95 OCTAVE_DEPRECATED ("use 'discard' instead") |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
96 void discard_top (int num) { discard (num); } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
97 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
98 size_t size (void) const { return lifo.size (); } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
99 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
100 protected: |
9376
d58086453171
refactor unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
101 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
102 std::stack<elem *> lifo; |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
103 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
104 private: |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
105 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
106 // No copying! |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
107 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
108 unwind_protect (const unwind_protect&); |
9394
b3ab22ee8544
further improve unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
9384
diff
changeset
|
109 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
110 unwind_protect& operator = (const unwind_protect&); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
111 }; |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
112 |
21751
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
113 // Like unwind_protect, but this one will guard against the possibility |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
114 // of seeing an exception (or interrupt) in the cleanup actions. |
b571fc85953f
maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents:
21743
diff
changeset
|
115 // Not that we can do much about it, but at least we won't crash. |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
116 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
117 class |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
118 OCTAVE_API |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
119 unwind_protect_safe : public unwind_protect |
15396 | 120 { |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
121 private: |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
122 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
123 void warn_unhandled_exception (void) const; |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9394
diff
changeset
|
124 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
125 public: |
9396
17af7cce7d1b
yet more unwind_protect improvements
Jaroslav Hajek <highegg@gmail.com>
parents:
9394
diff
changeset
|
126 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
127 unwind_protect_safe (void) : unwind_protect () { } |
9394
b3ab22ee8544
further improve unwind_protect
Jaroslav Hajek <highegg@gmail.com>
parents:
9384
diff
changeset
|
128 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
129 ~unwind_protect_safe (void) |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
130 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
131 while (! empty ()) |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
132 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
133 try |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
134 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
135 run_first (); |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
136 } |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
137 catch (...) // Yes, the black hole. Remember we're in a destructor. |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
138 { |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
139 warn_unhandled_exception (); |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
140 } |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
141 } |
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
142 } |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
143 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
144 private: |
15396 | 145 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
146 // No copying! |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
147 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
148 unwind_protect_safe (const unwind_protect_safe&); |
15396 | 149 |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
150 unwind_protect_safe& operator = (const unwind_protect_safe&); |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
151 }; |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
152 } |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
153 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
154 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
15396 | 155 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
156 OCTAVE_DEPRECATED ("use 'octave::unwind_protect' instead") |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
157 typedef octave::unwind_protect unwind_protect; |
15396 | 158 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21751
diff
changeset
|
159 OCTAVE_DEPRECATED ("use 'octave::unwind_protect_safe' instead") |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
160 typedef octave::unwind_protect_safe unwind_protect_safe; |
2985 | 161 |
1 | 162 #endif |
21743
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
163 |
f4d7d0eb5b0c
use namespace for unwind_protect class
John W. Eaton <jwe@octave.org>
parents:
21307
diff
changeset
|
164 #endif |
22402
4caa7b28d183
maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
165 |