annotate liboctave/system/child-list.h @ 30063:a8c61e096c68

maint: clean up some variable renamings in cset bffdbda91d28 * child-list.cc, child-list.h: Don't use "m_" prefix within function prototypes or for function parameters.
author Rik <rik@octave.org>
date Sun, 29 Aug 2021 19:59:28 -0700
parents bffdbda91d28
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 1993-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
22049
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 #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
27 #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
28
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29 #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
30
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <csignal>
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #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
34
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #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
36
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 namespace octave
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 {
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
39 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
40 {
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 public:
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
42
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 // 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
44 // 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
45 // 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
46 // 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
47 // the child_list.
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 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
50
30063
a8c61e096c68 maint: clean up some variable renamings in cset bffdbda91d28
Rik <rik@octave.org>
parents: 30049
diff changeset
51 child (pid_t pid = -1, child_event_handler f = nullptr)
a8c61e096c68 maint: clean up some variable renamings in cset bffdbda91d28
Rik <rik@octave.org>
parents: 30049
diff changeset
52 : m_pid (pid), m_handler (f), m_have_status (0), m_status (0)
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
53 { }
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54
24991
831389905438 omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents: 24736
diff changeset
55 child (const child&) = default;
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
56
24991
831389905438 omit argument name from default copy ctors and assignment operators
John W. Eaton <jwe@octave.org>
parents: 24736
diff changeset
57 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
58
22868
87e3163f6c87 use c++11 "= default" syntax for declaration of trivial destructors
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
59 ~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
60
30063
a8c61e096c68 maint: clean up some variable renamings in cset bffdbda91d28
Rik <rik@octave.org>
parents: 30049
diff changeset
61 // The process ID of this child.
30049
bffdbda91d28 maint: use "m_" prefix for member variables in child, child_list classes
Rik <rik@octave.org>
parents: 29358
diff changeset
62 pid_t m_pid;
22049
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 // The function we call if an event happens for this child.
30049
bffdbda91d28 maint: use "m_" prefix for member variables in child, child_list classes
Rik <rik@octave.org>
parents: 29358
diff changeset
65 child_event_handler m_handler;
22049
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 // Nonzero if this child has stopped or terminated.
30049
bffdbda91d28 maint: use "m_" prefix for member variables in child, child_list classes
Rik <rik@octave.org>
parents: 29358
diff changeset
68 sig_atomic_t m_have_status;
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69
30049
bffdbda91d28 maint: use "m_" prefix for member variables in child, child_list classes
Rik <rik@octave.org>
parents: 29358
diff changeset
70 // The m_status of this child; 0 if running, otherwise a m_status value
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71 // from waitpid.
30049
bffdbda91d28 maint: use "m_" prefix for member variables in child, child_list classes
Rik <rik@octave.org>
parents: 29358
diff changeset
72 int m_status;
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73 };
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
24736
cd25b9c5f808 eliminate useless public iterator typedefs in child_list class
John W. Eaton <jwe@octave.org>
parents: 24734
diff changeset
75 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
76 {
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
77 public:
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
78
22049
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 child_list (void) { }
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
30063
a8c61e096c68 maint: clean up some variable renamings in cset bffdbda91d28
Rik <rik@octave.org>
parents: 30049
diff changeset
81 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
82
30063
a8c61e096c68 maint: clean up some variable renamings in cset bffdbda91d28
Rik <rik@octave.org>
parents: 30049
diff changeset
83 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
84
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
85 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
86
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
87 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
88
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89 private:
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90
24734
5d8c4cbc56d7 don't use singleton pattern for child_list
John W. Eaton <jwe@octave.org>
parents: 24534
diff changeset
91 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
92 };
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 }
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
ccf50f029999 move octave_child_list to separate file and define inside namespace
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 #endif