1+ <?php
2+
3+ /*
4+ * Copyright (c) 2023 VennV
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+ declare (strict_types = 1 );
26+
27+ namespace vennv \vapm ;
28+
29+ class Threaded
30+ {
31+
32+ private int $ pid = -1 ;
33+
34+ private int $ exitCode = -1 ;
35+
36+ private bool $ isRunning = false ;
37+
38+ private bool $ signaled = false ;
39+
40+ private bool $ stopped = false ;
41+
42+ /**
43+ * @var array<string, mixed>
44+ * @phpstan-var array<string, mixed>
45+ */
46+ private static array $ shared = [];
47+
48+ public function __construct ()
49+ {}
50+
51+ public function getPid (): int
52+ {
53+ return $ this ->pid ;
54+ }
55+
56+ public function setPid (int $ pid ): void
57+ {
58+ $ this ->pid = $ pid ;
59+ }
60+
61+ public function getExitCode (): int
62+ {
63+ return $ this ->exitCode ;
64+ }
65+
66+ public function setExitCode (int $ exitCode ): void
67+ {
68+ $ this ->exitCode = $ exitCode ;
69+ }
70+
71+ public function isRunning (): bool
72+ {
73+ return $ this ->isRunning ;
74+ }
75+
76+ public function setRunning (bool $ isRunning ): void
77+ {
78+ $ this ->isRunning = $ isRunning ;
79+ }
80+
81+ public function isSignaled (): bool
82+ {
83+ return $ this ->signaled ;
84+ }
85+
86+ public function setSignaled (bool $ signaled ): void
87+ {
88+ $ this ->signaled = $ signaled ;
89+ }
90+
91+ public function isStopped (): bool
92+ {
93+ return $ this ->stopped ;
94+ }
95+
96+ public function setStopped (bool $ stopped ): void
97+ {
98+ $ this ->stopped = $ stopped ;
99+ }
100+
101+ /**
102+ * @return array<string, mixed>
103+ * @phpstan-return array<string, mixed>
104+ */
105+ public static function getShared (): array
106+ {
107+ return self ::$ shared ;
108+ }
109+
110+ /**
111+ * @param array<string, mixed> $shared
112+ * @phpstan-param array<string, mixed> $shared
113+ */
114+ public static function setShared (array $ shared ): void
115+ {
116+ self ::$ shared = $ shared ;
117+ }
118+
119+ public static function addShared (string $ key , mixed $ value ): void
120+ {
121+ self ::$ shared [$ key ] = $ value ;
122+ }
123+
124+ }
0 commit comments