comparison liboctave/system/child-list.cc @ 30173:f8ee588f1c7d

maint: Replace pid_equal helper class with lambda function. * child-list.cc: Delete pid_equal helper class. * child-list.cc (remove): Use lambda function in call to remove_if().
author Rik <rik@octave.org>
date Tue, 14 Sep 2021 10:34:28 -0700
parents a8c61e096c68
children 796f54d4ddbf
comparison
equal deleted inserted replaced
30172:dbfa0f70d9bd 30173:f8ee588f1c7d
30 #include "child-list.h" 30 #include "child-list.h"
31 #include "oct-syscalls.h" 31 #include "oct-syscalls.h"
32 32
33 namespace octave 33 namespace octave
34 { 34 {
35 class pid_equal
36 {
37 public:
38
39 pid_equal (pid_t v) : val (v) { }
40
41 bool operator () (const child& oc) const { return oc.m_pid == val; }
42
43 private:
44
45 pid_t val;
46 };
47
48 void child_list::remove (pid_t pid) 35 void child_list::remove (pid_t pid)
49 { 36 {
50 m_list.remove_if (pid_equal (pid)); 37 m_list.remove_if ([pid] (const child& oc) { return oc.m_pid == pid; });
51 } 38 }
52 39
53 void child_list::child_list::insert (pid_t pid, child::child_event_handler f) 40 void child_list::child_list::insert (pid_t pid, child::child_event_handler f)
54 { 41 {
55 m_list.append (child (pid, f)); 42 m_list.append (child (pid, f));