1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
consumerpollingtrait.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Calendar\Core\Queue\Impl
;
4
5
use
Bitrix\Calendar\Core\Queue\Interfaces
;
6
10
trait
ConsumerPollingTrait
11
{
16
protected
int
$pollingInterval = 1000;
17
21
public
function
setPollingInterval
(
int
$msec): self
22
{
23
$this->pollingInterval = $msec;
24
return
$this;
25
}
26
30
public
function
getPollingInterval
(): int
31
{
32
return
$this->pollingInterval;
33
}
34
35
public
function
receive
(
int
$timeout = 0): ?
Interfaces
\
Message
36
{
37
$timeout *= 1000;
// from milliseconds to microseconds
38
$startAt = microtime(
true
);
39
40
while
(
true
)
41
{
42
$message
= $this->receiveNoWait();
43
44
if
(
$message
)
45
{
46
return
$message
;
47
}
48
49
if
($timeout)
50
{
51
52
$timeSpent = microtime(
true
) - $startAt;
53
$timeSpent *= 1000000;
// from seconds to microseconds
54
$timeLeft = $timeout - $timeSpent;
55
56
// No time left to wait
57
if
($timeLeft <= 0)
58
{
59
return
null
;
60
}
61
62
// We pay attention not to wait too long to go over the timeout limit
63
$sleep = min($timeLeft, $this->pollingInterval * 1000);
64
65
}
66
else
67
{
68
$sleep = $this->pollingInterval * 1000;
69
}
70
71
usleep((
int
)$sleep);
72
}
73
}
74
}
Bitrix\Calendar\Core\Queue\Interfaces\Message
Определения
message.php:16
Bitrix\Calendar\Core\Queue\Impl
Определения
consumerpollingtrait.php:3
Bitrix\Calendar\Core\Queue\Impl\receive
receive(int $timeout=0)
Определения
consumerpollingtrait.php:35
Bitrix\Calendar\Core\Queue\Impl\ConsumerPollingTrait
trait ConsumerPollingTrait
Определения
consumerpollingtrait.php:11
Bitrix\Calendar\Core\Queue\Impl\getPollingInterval
getPollingInterval()
Определения
consumerpollingtrait.php:30
Bitrix\Calendar\Core\Queue\Impl\setPollingInterval
setPollingInterval(int $msec)
Определения
consumerpollingtrait.php:21
Bitrix\Calendar\Core\Queue\Interfaces
Определения
consumer.php:3
$message
$message
Определения
payment.php:8
bitrix
modules
calendar
lib
core
queue
impl
consumerpollingtrait.php
Создано системой
1.14.0