annotate libinterp/corefcn/event-queue.h @ 22869:f75d289645ec

make deleted functions public * octave-gui.h, resource-manager.h, shortcut-manager.h, base-text-renderer.h, c-file-ptr-stream.h, dynamic-ld.cc, dynamic-ld.h, event-queue.h, ft-text-renderer.cc, gl-render.cc, gl-render.h, graphics.cc, graphics.in.h, interpreter.h, mex.cc, mxarray.in.h, oct-fstrm.h, oct-iostrm.h, oct-prcstrm.h, oct-procbuf.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-link.h, pager.h, profiler.h, sighandlers.cc, symtab.h, text-renderer.h, zfstream.h, __init_fltk__.cc, ov-builtin.h, ov-dld-fcn.h, ov-fcn.h, ov-mex-fcn.h, ov-typeinfo.h, ov-usr-fcn.h, octave.h, lex.h, parse.h, pt-arg-list.h, pt-array-list.h, pt-assign.h, pt-binop.h, pt-bp.h, pt-cell.h, pt-check.h, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.h, pt-eval.h, pt-except.h, pt-exp.h, pt-fcn-handle.h, pt-funcall.h, pt-id.h, pt-idx.h, pt-jump.h, pt-loop.h, pt-mat.h, pt-misc.h, pt-pr-code.h, pt-select.h, pt-stmt.h, pt-unop.h, pt-walk.h, pt.h, token.h, Array.cc, idx-vector.h, oct-fftw.h, sparse-chol.cc, sparse-qr.cc, file-ops.h, mach-info.h, oct-env.h, action-container.h, cmd-edit.cc, cmd-edit.h, cmd-hist.h, oct-locbuf.h, oct-mutex.h, oct-shlib.cc, oct-sort.h, pathsearch.h, singleton-cleanup.h, unwind-prot.h, url-transfer.cc, url-transfer.h: Declare deleted copy constructors and assignment operators public.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Dec 2016 12:40:45 -0500
parents 89756f2f085b
children ef4d915df748
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
22323
bac0d6f07a3e maint: Update copyright notices for 2016.
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3 Copyright (C) 2012-2016 John W. Eaton
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
8 under the terms of the GNU General Public License as published by
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
9 the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
10 (at your option) any later version.
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
12 Octave is distributed in the hope that it will be useful, but
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22407
diff changeset
15 GNU General Public License for more details.
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 20545
diff changeset
23 #if ! defined (octave_event_queue_h)
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_event_queue_h 1
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21141
diff changeset
26 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21141
diff changeset
27
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <queue>
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #include <memory>
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include "action-container.h"
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 class
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 event_queue : public action_container
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 public:
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 event_queue (void) : fifo () { }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
40 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
41
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
42 event_queue (const event_queue&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
43
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
44 event_queue& operator = (const event_queue&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
45
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 // Destructor should not raise an exception, so all actions
20545
c547458dc10e eliminate error_state from most header files
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
47 // registered should be exception-safe. If you're not sure, see
c547458dc10e eliminate error_state from most header files
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
48 // event_queue_safe.
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 ~event_queue (void) { run (); }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 void add (elem *new_elem)
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 fifo.push (new_elem);
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 void run_first (void)
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 if (! empty ())
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 // No leak on exception!
21307
61c96c37ce69 Use std::unique_ptr to replace deprecated std::auto_ptr.
Rik <rik@octave.org>
parents: 21244
diff changeset
62 std::unique_ptr<elem> ptr (fifo.front ());
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 fifo.pop ();
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 ptr->run ();
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 void discard_first (void)
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 if (! empty ())
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 elem *ptr = fifo.front ();
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 fifo.pop ();
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 delete ptr;
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 size_t size (void) const { return fifo.size (); }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 protected:
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82 std::queue<elem *> fifo;
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 };
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 // Like event_queue, but this one will guard against the
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21307
diff changeset
86 // possibility 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: 21307
diff changeset
87 // Not that we can do much about it, but at least we won't crash.
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 class
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 event_queue_safe : public event_queue
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 {
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 private:
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93
21141
34368609f62b fix event-queue and unwind-protect exception warnings
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
94 void warn_unhandled_exception (void) const;
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 public:
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 event_queue_safe (void) : event_queue () { }
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99
22869
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
100 // No copying!
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
101
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
102 event_queue_safe (const event_queue_safe&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
103
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
104 event_queue_safe& operator = (const event_queue_safe&) = delete;
f75d289645ec make deleted functions public
John W. Eaton <jwe@octave.org>
parents: 22865
diff changeset
105
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 ~event_queue_safe (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
107 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
108 while (! empty ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
109 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
110 try
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
111 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
112 run_first ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
113 }
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21307
diff changeset
114 catch (...) // Yes, the black hole. Remember we're in a dtor.
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
115 {
21141
34368609f62b fix event-queue and unwind-protect exception warnings
John W. Eaton <jwe@octave.org>
parents: 20791
diff changeset
116 warn_unhandled_exception ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
117 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
118 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
119 }
15396
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 };
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121
1054ab58cd58 abstract unwind_protect
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122 #endif
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
123