Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
timer.php
1
<?php
9
namespace
Bitrix\Sender\Runtime
;
10
15
class
Timer
16
{
18
protected
$timeout
;
19
21
protected
$timeAtStart
;
22
24
protected
$limit
;
25
27
protected
$current
= 0;
28
30
protected
$isManualIncrement
=
false
;
31
38
public
function
__construct
(
$timeout
=
null
,
$limit
=
null
)
39
{
40
$this->
setLimit
(
$limit
)->setTimeout(
$timeout
)->startTime();
41
}
42
48
public
function
isElapsed
()
49
{
50
return
($this->
isTimeout
() || $this->
isLimitExceeded
());
51
}
52
58
public
function
enableManualIncrement
()
59
{
60
$this->isManualIncrement =
true
;
61
return
$this;
62
}
63
69
public
function
increment
()
70
{
71
$this->current++;
72
return
$this;
73
}
74
81
public
function
setLimit
(
$limit
)
82
{
83
$this->limit =
$limit
;
84
return
$this;
85
}
86
93
public
function
setTimeout
(
$timeout
)
94
{
95
$this->timeout =
$timeout
;
96
return
$this;
97
}
98
104
public
function
startTime
()
105
{
106
if
($this->timeout)
107
{
108
$this->timeAtStart = getmicrotime();
109
@set_time_limit(0);
110
}
111
112
return
$this;
113
}
114
120
public
function
isTimeout
()
121
{
122
if
(!$this->timeout)
123
{
124
return
false
;
125
}
126
127
return
(getmicrotime() - $this->timeAtStart >= $this->timeout);
128
}
129
135
public
function
isLimitExceeded
()
136
{
137
if
(!$this->limit)
138
{
139
return
false
;
140
}
141
142
if
(!$this->isManualIncrement)
143
{
144
$this->
increment
();
145
}
146
147
return
($this->current > $this->limit);
148
}
149
}
Bitrix\Sender\Runtime\Timer
Definition
timer.php:16
Bitrix\Sender\Runtime\Timer\increment
increment()
Definition
timer.php:69
Bitrix\Sender\Runtime\Timer\$current
$current
Definition
timer.php:27
Bitrix\Sender\Runtime\Timer\isElapsed
isElapsed()
Definition
timer.php:48
Bitrix\Sender\Runtime\Timer\setTimeout
setTimeout($timeout)
Definition
timer.php:93
Bitrix\Sender\Runtime\Timer\isLimitExceeded
isLimitExceeded()
Definition
timer.php:135
Bitrix\Sender\Runtime\Timer\$timeout
$timeout
Definition
timer.php:18
Bitrix\Sender\Runtime\Timer\startTime
startTime()
Definition
timer.php:104
Bitrix\Sender\Runtime\Timer\enableManualIncrement
enableManualIncrement()
Definition
timer.php:58
Bitrix\Sender\Runtime\Timer\$isManualIncrement
$isManualIncrement
Definition
timer.php:30
Bitrix\Sender\Runtime\Timer\$timeAtStart
$timeAtStart
Definition
timer.php:21
Bitrix\Sender\Runtime\Timer\$limit
$limit
Definition
timer.php:24
Bitrix\Sender\Runtime\Timer\isTimeout
isTimeout()
Definition
timer.php:120
Bitrix\Sender\Runtime\Timer\setLimit
setLimit($limit)
Definition
timer.php:81
Bitrix\Sender\Runtime\Timer\__construct
__construct($timeout=null, $limit=null)
Definition
timer.php:38
Bitrix\Sender\Runtime
Definition
env.php:9
modules
sender
lib
runtime
timer.php
Создано системой
1.10.0