@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | interface ListenerInterface |
8 | 8 | { |
9 | - /** |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function getEventMapping(): array; |
|
9 | + /** |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function getEventMapping(): array; |
|
13 | 13 | |
14 | - /** |
|
15 | - * @param EventInterface $event |
|
16 | - * @return void |
|
17 | - */ |
|
18 | - public function notify(EventInterface $event); |
|
14 | + /** |
|
15 | + * @param EventInterface $event |
|
16 | + * @return void |
|
17 | + */ |
|
18 | + public function notify(EventInterface $event); |
|
19 | 19 | |
20 | 20 | } |
@@ -8,54 +8,54 @@ |
||
8 | 8 | |
9 | 9 | abstract class AbstractThreadPoolMediator |
10 | 10 | { |
11 | - /** @var Mediator */ |
|
12 | - private $mediator; |
|
13 | - |
|
14 | - /** |
|
15 | - * @return Mediator |
|
16 | - */ |
|
17 | - protected function getMediator() |
|
18 | - { |
|
19 | - return $this->mediator; |
|
20 | - } |
|
21 | - |
|
22 | - /** |
|
23 | - * ThreadPoolMediator constructor. |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - $this->mediator = new Mediator(); |
|
28 | - } |
|
29 | - |
|
30 | - /** |
|
31 | - * @param ListenerInterface $listener |
|
32 | - * @return AbstractThreadPoolMediator |
|
33 | - */ |
|
34 | - public function addListener(ListenerInterface $listener): self |
|
35 | - { |
|
36 | - $this->mediator->addListener($listener); |
|
37 | - |
|
38 | - return $this; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param ListenerInterface $listener |
|
43 | - * @return AbstractThreadPoolMediator |
|
44 | - */ |
|
45 | - public function removeListener(ListenerInterface $listener): self |
|
46 | - { |
|
47 | - $this->mediator->removeListener($listener); |
|
48 | - |
|
49 | - return $this; |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * @param string $eventName |
|
54 | - * @param AbstractThread|null $thread |
|
55 | - */ |
|
56 | - protected function notify(string $eventName, ?AbstractThread $thread = null) |
|
57 | - { |
|
58 | - $this->getMediator()->notify(EventPoolFactory::create($eventName, $this, $thread)); |
|
59 | - } |
|
11 | + /** @var Mediator */ |
|
12 | + private $mediator; |
|
13 | + |
|
14 | + /** |
|
15 | + * @return Mediator |
|
16 | + */ |
|
17 | + protected function getMediator() |
|
18 | + { |
|
19 | + return $this->mediator; |
|
20 | + } |
|
21 | + |
|
22 | + /** |
|
23 | + * ThreadPoolMediator constructor. |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + $this->mediator = new Mediator(); |
|
28 | + } |
|
29 | + |
|
30 | + /** |
|
31 | + * @param ListenerInterface $listener |
|
32 | + * @return AbstractThreadPoolMediator |
|
33 | + */ |
|
34 | + public function addListener(ListenerInterface $listener): self |
|
35 | + { |
|
36 | + $this->mediator->addListener($listener); |
|
37 | + |
|
38 | + return $this; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param ListenerInterface $listener |
|
43 | + * @return AbstractThreadPoolMediator |
|
44 | + */ |
|
45 | + public function removeListener(ListenerInterface $listener): self |
|
46 | + { |
|
47 | + $this->mediator->removeListener($listener); |
|
48 | + |
|
49 | + return $this; |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * @param string $eventName |
|
54 | + * @param AbstractThread|null $thread |
|
55 | + */ |
|
56 | + protected function notify(string $eventName, ?AbstractThread $thread = null) |
|
57 | + { |
|
58 | + $this->getMediator()->notify(EventPoolFactory::create($eventName, $this, $thread)); |
|
59 | + } |
|
60 | 60 | |
61 | 61 | } |
@@ -7,186 +7,186 @@ |
||
7 | 7 | |
8 | 8 | class PoolEvent implements EventInterface |
9 | 9 | { |
10 | - const POOL_RUN_START = 'run_start'; |
|
11 | - const POOL_RUN_STOP = 'run_stop'; |
|
12 | - const POOL_NEW_THREAD = 'new_thread'; |
|
13 | - const POOL_PRE_WAIT_TICK = 'pre_wait_tick'; |
|
14 | - const POOL_POST_WAIT_TICK = 'post_wait_tick'; |
|
15 | - const POOL_WAIT_TICK_PID = 'wait_tick_pid'; |
|
16 | - const POOL_WAIT_TICK_PID_REMOVED = 'wait_tick_pid_removed'; |
|
17 | - |
|
18 | - const THREAD_PRE_PROCESS = 'pre_process'; |
|
19 | - const THREAD_POST_PROCESS = 'post_process'; |
|
20 | - const THREAD_EXIT_SUCCESS = 'exist_success'; |
|
21 | - const THREAD_EXIT_ERROR = 'exit_error'; |
|
22 | - const THREAD_EXIT_UNKNOWN = 'exit_unknown'; |
|
23 | - |
|
24 | - /** @var string $eventName */ |
|
25 | - private $eventName; |
|
26 | - |
|
27 | - /** @var int $threadNb */ |
|
28 | - private $threadNb; |
|
29 | - |
|
30 | - /** @var int $runningThreadNb */ |
|
31 | - private $runningThreadNb; |
|
32 | - |
|
33 | - /** @var int $threadDoneNb */ |
|
34 | - private $threadDoneNb; |
|
35 | - |
|
36 | - /** @var int $threadLeftNb */ |
|
37 | - private $threadLeftNb; |
|
38 | - |
|
39 | - /** @var int $maxRunningThreadNb */ |
|
40 | - private $maxRunningThreadNb; |
|
41 | - |
|
42 | - /** @var AbstractThread $thread */ |
|
43 | - private $thread; |
|
44 | - |
|
45 | - /** |
|
46 | - * ThreadPoolEvent constructor. |
|
47 | - * @param string $eventName |
|
48 | - */ |
|
49 | - public function __construct($eventName) |
|
50 | - { |
|
51 | - $this->eventName = $eventName; |
|
52 | - $this->threadNb = 0; |
|
53 | - $this->runningThreadNb = 0; |
|
54 | - $this->threadDoneNb = 0; |
|
55 | - $this->threadLeftNb = 0; |
|
56 | - $this->maxRunningThreadNb = 0; |
|
57 | - } |
|
58 | - |
|
59 | - /** |
|
60 | - * @return string |
|
61 | - */ |
|
62 | - public function getEventName(): string |
|
63 | - { |
|
64 | - return $this->eventName; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * @param string $eventName |
|
69 | - * @return PoolEvent |
|
70 | - */ |
|
71 | - public function setEventName(string $eventName): self |
|
72 | - { |
|
73 | - $this->eventName = $eventName; |
|
74 | - |
|
75 | - return $this; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return int |
|
80 | - */ |
|
81 | - public function getThreadNb(): int |
|
82 | - { |
|
83 | - return $this->threadNb; |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * @param int $threadNb |
|
88 | - * @return PoolEvent |
|
89 | - */ |
|
90 | - public function setThreadNb(int $threadNb): self |
|
91 | - { |
|
92 | - $this->threadNb = $threadNb; |
|
93 | - |
|
94 | - return $this; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @return int |
|
99 | - */ |
|
100 | - public function getThreadDoneNb(): int |
|
101 | - { |
|
102 | - return $this->threadDoneNb; |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * @param int $threadDoneNb |
|
107 | - * @return PoolEvent |
|
108 | - */ |
|
109 | - public function setThreadDoneNb(int $threadDoneNb): self |
|
110 | - { |
|
111 | - $this->threadDoneNb = $threadDoneNb; |
|
112 | - |
|
113 | - return $this; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @return int |
|
118 | - */ |
|
119 | - public function getThreadLeftNb(): int |
|
120 | - { |
|
121 | - return $this->threadLeftNb; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * @param int $threadLeftNb |
|
126 | - * @return PoolEvent |
|
127 | - */ |
|
128 | - public function setThreadLeftNb(int $threadLeftNb): self |
|
129 | - { |
|
130 | - $this->threadLeftNb = $threadLeftNb; |
|
131 | - |
|
132 | - return $this; |
|
133 | - } |
|
134 | - |
|
135 | - /** |
|
136 | - * @return int |
|
137 | - */ |
|
138 | - public function getMaxRunningThreadNb(): int |
|
139 | - { |
|
140 | - return $this->maxRunningThreadNb; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * @param int $maxRunningThreadNb |
|
145 | - * @return PoolEvent |
|
146 | - */ |
|
147 | - public function setMaxRunningThreadNb(int $maxRunningThreadNb): self |
|
148 | - { |
|
149 | - $this->maxRunningThreadNb = $maxRunningThreadNb; |
|
150 | - |
|
151 | - return $this; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @return int |
|
156 | - */ |
|
157 | - public function getRunningThreadNb(): int |
|
158 | - { |
|
159 | - return $this->runningThreadNb; |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * @param int $runningThreadNb |
|
164 | - * @return PoolEvent |
|
165 | - */ |
|
166 | - public function setRunningThreadNb(int $runningThreadNb): self |
|
167 | - { |
|
168 | - $this->runningThreadNb = $runningThreadNb; |
|
169 | - |
|
170 | - return $this; |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * @return AbstractThread |
|
175 | - */ |
|
176 | - public function getThread(): ?AbstractThread |
|
177 | - { |
|
178 | - return $this->thread; |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * @param AbstractThread|null $thread |
|
183 | - * @return $this |
|
184 | - */ |
|
185 | - public function setThread(AbstractThread $thread = null): self |
|
186 | - { |
|
187 | - $this->thread = $thread; |
|
188 | - |
|
189 | - return $this; |
|
190 | - } |
|
10 | + const POOL_RUN_START = 'run_start'; |
|
11 | + const POOL_RUN_STOP = 'run_stop'; |
|
12 | + const POOL_NEW_THREAD = 'new_thread'; |
|
13 | + const POOL_PRE_WAIT_TICK = 'pre_wait_tick'; |
|
14 | + const POOL_POST_WAIT_TICK = 'post_wait_tick'; |
|
15 | + const POOL_WAIT_TICK_PID = 'wait_tick_pid'; |
|
16 | + const POOL_WAIT_TICK_PID_REMOVED = 'wait_tick_pid_removed'; |
|
17 | + |
|
18 | + const THREAD_PRE_PROCESS = 'pre_process'; |
|
19 | + const THREAD_POST_PROCESS = 'post_process'; |
|
20 | + const THREAD_EXIT_SUCCESS = 'exist_success'; |
|
21 | + const THREAD_EXIT_ERROR = 'exit_error'; |
|
22 | + const THREAD_EXIT_UNKNOWN = 'exit_unknown'; |
|
23 | + |
|
24 | + /** @var string $eventName */ |
|
25 | + private $eventName; |
|
26 | + |
|
27 | + /** @var int $threadNb */ |
|
28 | + private $threadNb; |
|
29 | + |
|
30 | + /** @var int $runningThreadNb */ |
|
31 | + private $runningThreadNb; |
|
32 | + |
|
33 | + /** @var int $threadDoneNb */ |
|
34 | + private $threadDoneNb; |
|
35 | + |
|
36 | + /** @var int $threadLeftNb */ |
|
37 | + private $threadLeftNb; |
|
38 | + |
|
39 | + /** @var int $maxRunningThreadNb */ |
|
40 | + private $maxRunningThreadNb; |
|
41 | + |
|
42 | + /** @var AbstractThread $thread */ |
|
43 | + private $thread; |
|
44 | + |
|
45 | + /** |
|
46 | + * ThreadPoolEvent constructor. |
|
47 | + * @param string $eventName |
|
48 | + */ |
|
49 | + public function __construct($eventName) |
|
50 | + { |
|
51 | + $this->eventName = $eventName; |
|
52 | + $this->threadNb = 0; |
|
53 | + $this->runningThreadNb = 0; |
|
54 | + $this->threadDoneNb = 0; |
|
55 | + $this->threadLeftNb = 0; |
|
56 | + $this->maxRunningThreadNb = 0; |
|
57 | + } |
|
58 | + |
|
59 | + /** |
|
60 | + * @return string |
|
61 | + */ |
|
62 | + public function getEventName(): string |
|
63 | + { |
|
64 | + return $this->eventName; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * @param string $eventName |
|
69 | + * @return PoolEvent |
|
70 | + */ |
|
71 | + public function setEventName(string $eventName): self |
|
72 | + { |
|
73 | + $this->eventName = $eventName; |
|
74 | + |
|
75 | + return $this; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return int |
|
80 | + */ |
|
81 | + public function getThreadNb(): int |
|
82 | + { |
|
83 | + return $this->threadNb; |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * @param int $threadNb |
|
88 | + * @return PoolEvent |
|
89 | + */ |
|
90 | + public function setThreadNb(int $threadNb): self |
|
91 | + { |
|
92 | + $this->threadNb = $threadNb; |
|
93 | + |
|
94 | + return $this; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @return int |
|
99 | + */ |
|
100 | + public function getThreadDoneNb(): int |
|
101 | + { |
|
102 | + return $this->threadDoneNb; |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * @param int $threadDoneNb |
|
107 | + * @return PoolEvent |
|
108 | + */ |
|
109 | + public function setThreadDoneNb(int $threadDoneNb): self |
|
110 | + { |
|
111 | + $this->threadDoneNb = $threadDoneNb; |
|
112 | + |
|
113 | + return $this; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @return int |
|
118 | + */ |
|
119 | + public function getThreadLeftNb(): int |
|
120 | + { |
|
121 | + return $this->threadLeftNb; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * @param int $threadLeftNb |
|
126 | + * @return PoolEvent |
|
127 | + */ |
|
128 | + public function setThreadLeftNb(int $threadLeftNb): self |
|
129 | + { |
|
130 | + $this->threadLeftNb = $threadLeftNb; |
|
131 | + |
|
132 | + return $this; |
|
133 | + } |
|
134 | + |
|
135 | + /** |
|
136 | + * @return int |
|
137 | + */ |
|
138 | + public function getMaxRunningThreadNb(): int |
|
139 | + { |
|
140 | + return $this->maxRunningThreadNb; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * @param int $maxRunningThreadNb |
|
145 | + * @return PoolEvent |
|
146 | + */ |
|
147 | + public function setMaxRunningThreadNb(int $maxRunningThreadNb): self |
|
148 | + { |
|
149 | + $this->maxRunningThreadNb = $maxRunningThreadNb; |
|
150 | + |
|
151 | + return $this; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @return int |
|
156 | + */ |
|
157 | + public function getRunningThreadNb(): int |
|
158 | + { |
|
159 | + return $this->runningThreadNb; |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * @param int $runningThreadNb |
|
164 | + * @return PoolEvent |
|
165 | + */ |
|
166 | + public function setRunningThreadNb(int $runningThreadNb): self |
|
167 | + { |
|
168 | + $this->runningThreadNb = $runningThreadNb; |
|
169 | + |
|
170 | + return $this; |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * @return AbstractThread |
|
175 | + */ |
|
176 | + public function getThread(): ?AbstractThread |
|
177 | + { |
|
178 | + return $this->thread; |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * @param AbstractThread|null $thread |
|
183 | + * @return $this |
|
184 | + */ |
|
185 | + public function setThread(AbstractThread $thread = null): self |
|
186 | + { |
|
187 | + $this->thread = $thread; |
|
188 | + |
|
189 | + return $this; |
|
190 | + } |
|
191 | 191 | |
192 | 192 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | use Wonderland\Thread\Example\Simple\TestThread; |
5 | 5 | use Wonderland\Thread\ThreadPool; |
6 | 6 | |
7 | -require __DIR__.'/../../vendor/autoload.php'; |
|
7 | +require __DIR__ . '/../../vendor/autoload.php'; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @param $increment |
@@ -18,19 +18,19 @@ |
||
18 | 18 | class EventPoolFactoryTest extends TestCase |
19 | 19 | { |
20 | 20 | |
21 | - public function test_create() |
|
22 | - { |
|
23 | - $pool = new ThreadPool(); |
|
24 | - $thread = new SuccessThread('unit-test'); |
|
25 | - $event = new PoolEvent('unit-test'); |
|
26 | - $factoryEvent = EventPoolFactory::create('unit-test', $pool, $thread); |
|
21 | + public function test_create() |
|
22 | + { |
|
23 | + $pool = new ThreadPool(); |
|
24 | + $thread = new SuccessThread('unit-test'); |
|
25 | + $event = new PoolEvent('unit-test'); |
|
26 | + $factoryEvent = EventPoolFactory::create('unit-test', $pool, $thread); |
|
27 | 27 | |
28 | - $this->assertSame($event->getEventName(), $factoryEvent->getEventName()); |
|
29 | - $this->assertSame($event->getThreadLeftNb(), $factoryEvent->getThreadLeftNb()); |
|
30 | - $this->assertSame($event->getMaxRunningThreadNb(), $factoryEvent->getMaxRunningThreadNb()); |
|
31 | - $this->assertSame($event->getRunningThreadNb(), $factoryEvent->getRunningThreadNb()); |
|
32 | - $this->assertSame($event->getThreadDoneNb(), $factoryEvent->getThreadDoneNb()); |
|
33 | - $this->assertSame($event->getThreadNb(), $factoryEvent->getThreadNb()); |
|
34 | - } |
|
28 | + $this->assertSame($event->getEventName(), $factoryEvent->getEventName()); |
|
29 | + $this->assertSame($event->getThreadLeftNb(), $factoryEvent->getThreadLeftNb()); |
|
30 | + $this->assertSame($event->getMaxRunningThreadNb(), $factoryEvent->getMaxRunningThreadNb()); |
|
31 | + $this->assertSame($event->getRunningThreadNb(), $factoryEvent->getRunningThreadNb()); |
|
32 | + $this->assertSame($event->getThreadDoneNb(), $factoryEvent->getThreadDoneNb()); |
|
33 | + $this->assertSame($event->getThreadNb(), $factoryEvent->getThreadNb()); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | } |
@@ -7,31 +7,31 @@ |
||
7 | 7 | class SuccessThread extends AbstractThread |
8 | 8 | { |
9 | 9 | |
10 | - public function method() |
|
11 | - { |
|
12 | - $this->notify(new TestEvent()); |
|
13 | - |
|
14 | - return self::EXIT_STATUS_SUCCESS; |
|
15 | - } |
|
16 | - |
|
17 | - /** |
|
18 | - * Return the name of the method to process during the thread |
|
19 | - * |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - protected function getMethodName(): string |
|
23 | - { |
|
24 | - return 'method'; |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Return the list of dependencies that will be passed as parameters of the method referenced by getMethodName |
|
29 | - * |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - protected function getDependencies(): array |
|
33 | - { |
|
34 | - return ['toto']; |
|
35 | - } |
|
10 | + public function method() |
|
11 | + { |
|
12 | + $this->notify(new TestEvent()); |
|
13 | + |
|
14 | + return self::EXIT_STATUS_SUCCESS; |
|
15 | + } |
|
16 | + |
|
17 | + /** |
|
18 | + * Return the name of the method to process during the thread |
|
19 | + * |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + protected function getMethodName(): string |
|
23 | + { |
|
24 | + return 'method'; |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Return the list of dependencies that will be passed as parameters of the method referenced by getMethodName |
|
29 | + * |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + protected function getDependencies(): array |
|
33 | + { |
|
34 | + return ['toto']; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | } |
@@ -7,29 +7,29 @@ |
||
7 | 7 | class ErrorThread extends AbstractThread |
8 | 8 | { |
9 | 9 | |
10 | - public function method() |
|
11 | - { |
|
12 | - return null; |
|
13 | - } |
|
10 | + public function method() |
|
11 | + { |
|
12 | + return null; |
|
13 | + } |
|
14 | 14 | |
15 | - /** |
|
16 | - * Return the name of the method to process during the thread |
|
17 | - * |
|
18 | - * @return string |
|
19 | - */ |
|
20 | - protected function getMethodName(): string |
|
21 | - { |
|
22 | - return 'method'; |
|
23 | - } |
|
15 | + /** |
|
16 | + * Return the name of the method to process during the thread |
|
17 | + * |
|
18 | + * @return string |
|
19 | + */ |
|
20 | + protected function getMethodName(): string |
|
21 | + { |
|
22 | + return 'method'; |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Return the list of dependencies that will be passed as parameters of the method referenced by getMethodName |
|
27 | - * |
|
28 | - * @return array |
|
29 | - */ |
|
30 | - protected function getDependencies(): array |
|
31 | - { |
|
32 | - return ['toto']; |
|
33 | - } |
|
25 | + /** |
|
26 | + * Return the list of dependencies that will be passed as parameters of the method referenced by getMethodName |
|
27 | + * |
|
28 | + * @return array |
|
29 | + */ |
|
30 | + protected function getDependencies(): array |
|
31 | + { |
|
32 | + return ['toto']; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | } |
@@ -8,22 +8,22 @@ |
||
8 | 8 | class TestListener extends AbstractListener |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * @return array |
|
13 | - */ |
|
14 | - public function getEventMapping(): array |
|
15 | - { |
|
16 | - return [ |
|
17 | - PoolEvent::POOL_NEW_THREAD => 'onNewThread' |
|
18 | - ]; |
|
19 | - } |
|
11 | + /** |
|
12 | + * @return array |
|
13 | + */ |
|
14 | + public function getEventMapping(): array |
|
15 | + { |
|
16 | + return [ |
|
17 | + PoolEvent::POOL_NEW_THREAD => 'onNewThread' |
|
18 | + ]; |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * @param PoolEvent $event |
|
23 | - */ |
|
24 | - public function onNewThread(PoolEvent $event) |
|
25 | - { |
|
21 | + /** |
|
22 | + * @param PoolEvent $event |
|
23 | + */ |
|
24 | + public function onNewThread(PoolEvent $event) |
|
25 | + { |
|
26 | 26 | |
27 | - } |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
@@ -7,12 +7,12 @@ |
||
7 | 7 | class TestEvent implements EventInterface |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @return string |
|
12 | - */ |
|
13 | - public function getEventName(): string |
|
14 | - { |
|
15 | - return 'test-unit-event'; |
|
16 | - } |
|
10 | + /** |
|
11 | + * @return string |
|
12 | + */ |
|
13 | + public function getEventName(): string |
|
14 | + { |
|
15 | + return 'test-unit-event'; |
|
16 | + } |
|
17 | 17 | |
18 | 18 | } |