Completed
Push — master ( a12146...64a44a )
by Joao
02:25
created
example.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,17 +4,17 @@  discard block
 block discarded – undo
4 4
 // Method to be executed in a thread
5 5
 function Foo($t)
6 6
 {
7
-    echo "Starting thread #$t" . PHP_EOL;
7
+    echo "Starting thread #$t".PHP_EOL;
8 8
     
9 9
     sleep(1 * rand(1, 5));
10 10
     for ($i = 0; $i < 10; $i++) {
11
-        echo "Hello from thread #$t, i=$i" . PHP_EOL;
11
+        echo "Hello from thread #$t, i=$i".PHP_EOL;
12 12
         sleep(1);
13 13
     }
14
-    echo "Ending thread #$t" . PHP_EOL;
14
+    echo "Ending thread #$t".PHP_EOL;
15 15
 
16 16
     // Note: this line below require the file "config/cacheconfig.php" exists
17
-    return "$t: [[[[[[" . time() . "]]]]]]";
17
+    return "$t: [[[[[[".time()."]]]]]]";
18 18
 }
19 19
 
20 20
 try {
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
 
52 52
     // Note: this line below require the file "config/cacheconfig.php" exists
53 53
     foreach ($t as $thread) {
54
-        echo "Result: " . $thread->getResult() . "\n";
54
+        echo "Result: ".$thread->getResult()."\n";
55 55
     }
56 56
     
57 57
 } catch (Exception $e) {
58
-    echo 'Exception: ' . $e . PHP_EOL;
58
+    echo 'Exception: '.$e.PHP_EOL;
59 59
 }
Please login to merge, or discard this patch.
src/Handler/ForkHandler.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
      */
74 74
     public function start()
75 75
     {
76
-        $this->_threadKey = 'thread_' . rand(1000, 9999) . rand(1000, 9999) . rand(1000, 9999) . rand(1000, 9999);
76
+        $this->_threadKey = 'thread_'.rand(1000, 9999).rand(1000, 9999).rand(1000, 9999).rand(1000, 9999);
77 77
 
78 78
         if (($this->_pid = pcntl_fork()) == -1) {
79 79
             throw new RuntimeException('Couldn\'t fork the process');
Please login to merge, or discard this patch.
src/Handler/PThreadHandler.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
             return $this->loader;
40 40
         }
41 41
 
42
-        $path = __DIR__ . '/../../vendor/autoload.php';
42
+        $path = __DIR__.'/../../vendor/autoload.php';
43 43
         if (!file_exists($path)) {
44
-            $path = __DIR__ . '/../../../../autoload.php';
44
+            $path = __DIR__.'/../../../../autoload.php';
45 45
             if (!file_exists($path)) {
46 46
                 throw new \RuntimeException("Autoload path '$path' not found");
47 47
             }
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      */
88 88
     public function getResult()
89 89
     {
90
-        if ($this->hasError && ( $this->hasError['type'] == E_ERROR || $this->hasError['type'] == E_USER_ERROR )) {
90
+        if ($this->hasError && ($this->hasError['type'] == E_ERROR || $this->hasError['type'] == E_USER_ERROR)) {
91 91
             throw new \RuntimeException(
92 92
                 sprintf(
93 93
                     'Thread error: "%s", in "%s" at line %d. <<--- ',
Please login to merge, or discard this patch.
example_pool.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@  discard block
 block discarded – undo
5 5
 // Method to be executed in a thread
6 6
 function Foo($t)
7 7
 {
8
-    echo "Starting thread #$t" . PHP_EOL;;
8
+    echo "Starting thread #$t".PHP_EOL; ;
9 9
     sleep(1 * rand(1, 5));
10 10
     for ($i = 0; $i < 10; $i++) {
11
-        echo "Hello from thread #$t, i=$i" . PHP_EOL;
11
+        echo "Hello from thread #$t, i=$i".PHP_EOL;
12 12
         sleep(1);
13 13
     }
14
-    echo "Ending thread #$t" . PHP_EOL;
14
+    echo "Ending thread #$t".PHP_EOL;
15 15
 
16 16
     return uniqid("Thread_{$t}_");
17 17
 }
@@ -33,18 +33,18 @@  discard block
 block discarded – undo
33 33
     // Wait until there is no more active workers
34 34
     // You can use $threadPool->waitWorkers() instead the loop below
35 35
     while ($threadPool->activeWorkers() > 0) {
36
-        echo "Active Workers : " . $threadPool->activeWorkers() . "\n";
36
+        echo "Active Workers : ".$threadPool->activeWorkers()."\n";
37 37
         sleep(1);
38 38
     }
39 39
 
40 40
     // Get the return value from the thread.
41 41
     foreach ($threadPool->getThreads() as $thid) {
42
-        echo 'Result: ' . $threadPool->getThreadResult($thid) . "\n";
42
+        echo 'Result: '.$threadPool->getThreadResult($thid)."\n";
43 43
     }
44 44
 
45 45
     echo "\n\nEnded!\n";
46 46
 
47 47
 } catch (Exception $e) {
48
-    echo 'Exception: ' . $e . PHP_EOL;
48
+    echo 'Exception: '.$e.PHP_EOL;
49 49
 }
50 50
 
Please login to merge, or discard this patch.