InitializeTips::waiting()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Initialize tips for resources
4
 * User: moyo
5
 * Date: 2018/4/11
6
 * Time: 11:15 AM
7
 */
8
9
namespace Carno\Cluster\Chips;
10
11
use Carno\Cluster\Managed;
12
use Carno\Timer\Timer;
13
14
trait InitializeTips
15
{
16
    /**
17
     * @var array
18
     */
19
    private $checker = [];
20
21
    /**
22
     * @param string $sk
23
     * @param Managed $managed
24
     */
25
    private function waiting(string $sk, Managed $managed) : void
26
    {
27
        $oid = spl_object_id($managed);
28
29
        $this->checker[$oid] = Timer::loop(30000, function () use ($sk) {
30
            logger('cluster')->notice('Now is waiting', ['resource' => $sk]);
31
        });
32
33
        $managed->joined(function () use ($oid) {
34
            Timer::clear($this->checker[$oid]);
35
        });
36
    }
37
}
38