annotate liboctave/system/child-list.h @ 24991:831389905438 stable

omit argument name from default copy ctors and assignment operators * thread-manager.h, fcn-info.h, graphics.in.h, load-path.h, oct-stream.cc, pr-flt-fmt.h, symrec.h, octave.h, oct-lvalue.h, child-list.h, pathsearch.h, url-transfer.h: Use "(const foo&)" instead of "(const foo& arg)" for declaration of default copy constructors and assignment operators.
author John W. Eaton <jwe@octave.org>
date Mon, 26 Mar 2018 13:10:42 -0400
parents cd25b9c5f808
children 6652d3823428
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 /*
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
3 Copyright (C) 1993-2017 John W. Eaton
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 This file is part of Octave.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
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: 22402
diff changeset
8 under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
9 the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
10 (at your option) any later version.
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
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: 22402
diff changeset
13 WITHOUT ANY WARRANTY; without even the implied warranty of
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22402
diff changeset
15 GNU General Public License for more details.
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23795
diff changeset
19 <https://www.gnu.org/licenses/>.
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 */
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 #if ! defined (octave_child_list_h)
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 #define octave_child_list_h 1
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #include "octave-config.h"
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #include <csignal>
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <sys/types.h>
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "base-list.h"
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 namespace octave
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 {
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
36 class OCTAVE_API child
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 {
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 public:
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 // Do whatever to handle event for child with PID (might not
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 // actually be dead, could just be stopped). Return true if
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42 // the list element corresponding to PID should be removed from
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 // list. This function should not call any functions that modify
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 // the child_list.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 typedef bool (*child_event_handler) (pid_t, int);
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23615
diff changeset
48 child (pid_t id = -1, child_event_handler f = nullptr)
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
49 : pid (id), handler (f), have_status (0), status (0)
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
50 { }
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
24991
831389905438 omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents: 24736
diff changeset
52 child (const child&) = default;
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53
24991
831389905438 omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents: 24736
diff changeset
54 child& operator = (const child&) = default;
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
56 ~child (void) = default;
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58 // The process id of this child.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 pid_t pid;
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 // The function we call if an event happens for this child.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62 child_event_handler handler;
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 // Nonzero if this child has stopped or terminated.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 sig_atomic_t have_status;
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 // The status of this child; 0 if running, otherwise a status value
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 // from waitpid.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 int status;
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 };
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
24736
cd25b9c5f808 eliminate useless public iterator typedefs in child_list class
John W. Eaton <jwe@octave.org>
parents: 24734
diff changeset
72 class OCTAVE_API child_list
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 {
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
74 public:
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
75
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 child_list (void) { }
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
78 void insert (pid_t pid, child::child_event_handler f);
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
80 void remove (pid_t pid);
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
82 void reap (void);
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
84 bool wait (void);
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86 private:
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
88 base_list<child> m_list;
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 };
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 }
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 #endif