@@ 89-106 (lines=18) @@ | ||
86 | * @return bool |
|
87 | * @throws Exception |
|
88 | */ |
|
89 | protected function createIPCSegment() |
|
90 | { |
|
91 | $this->fileIPC1 = '/tmp/' . mt_rand() . md5($this->getName()) . '.shm'; |
|
92 | ||
93 | touch($this->fileIPC1); |
|
94 | ||
95 | $shm_key = ftok($this->fileIPC1, 't'); |
|
96 | if ($shm_key === -1) { |
|
97 | throw new Exception('Fatal exception creating SHM segment (ftok)'); |
|
98 | } |
|
99 | ||
100 | $this->internalIPCKey = @shmop_open($shm_key, 'c', 0644, 10240); |
|
101 | if (!$this->internalIPCKey) { |
|
102 | return false; |
|
103 | } |
|
104 | ||
105 | return true; |
|
106 | } |
|
107 | ||
108 | /** |
|
109 | * get thread name |
|
@@ 140-157 (lines=18) @@ | ||
137 | * @return bool |
|
138 | * @throws Exception |
|
139 | */ |
|
140 | protected function createIPCSemaphore() |
|
141 | { |
|
142 | $this->fileIPC2 = '/tmp/' . mt_rand() . md5($this->getName()) . '.sem'; |
|
143 | ||
144 | touch($this->fileIPC2); |
|
145 | ||
146 | $sem_key = ftok($this->fileIPC2, 't'); |
|
147 | if ($sem_key === -1) { |
|
148 | throw new Exception('Fatal exception creating semaphore (ftok)'); |
|
149 | } |
|
150 | ||
151 | $this->internalSemaphoreKey = shmop_open($sem_key, 'c', 0644, 10); |
|
152 | if (!$this->internalSemaphoreKey) { |
|
153 | return false; |
|
154 | } |
|
155 | ||
156 | return true; |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * Is running thread |