Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5973074
BasicRequestTimeout.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
BasicRequestTimeout.php
View Options
<?php
namespace
Wikimedia\RequestTimeout\Detail
;
use
Wikimedia\RequestTimeout\RequestTimeout
;
/**
* A fallback implementation used when Excimer is not available
*/
class
BasicRequestTimeout
extends
RequestTimeout
{
/** @var float */
private
$limit
;
/** @var float */
private
$startTime
;
/** @var int The next critical section ID to use */
private
$nextCriticalId
=
1
;
public
function
enterCriticalSection
(
$name
,
$emergencyLimit
,
$emergencyCallback
)
{
return
$this
->
nextCriticalId
++;
}
public
function
exitCriticalSection
(
$id
)
{
}
/**
* Get the elapsed CPU time. This can be used to estimate when the time
* limit will expire.
*
* @return float
*/
private
function
getCpuTime
()
{
$r
=
getrusage
();
return
$r
[
'ru_utime.tv_sec'
]
+
$r
[
'ru_stime.tv_sec'
]
+
(
$r
[
'ru_utime.tv_usec'
]
+
$r
[
'ru_stime.tv_usec'
]
)
*
1e-6
;
}
public
function
setWallTimeLimit
(
$limit
)
{
if
(
$limit
===
INF
)
{
$limit
=
0
;
}
$this
->
limit
=
ceil
(
$limit
);
$this
->
startTime
=
$this
->
getCpuTime
();
set_time_limit
(
$this
->
limit
);
}
public
function
getWallTimeRemaining
()
{
if
(
$this
->
startTime
!==
null
&&
$this
->
limit
>
0
)
{
return
$this
->
limit
-
$this
->
getCpuTime
()
+
$this
->
startTime
;
}
else
{
return
INF
;
}
}
public
function
getWallTimeLimit
()
{
if
(
$this
->
limit
>
0
)
{
return
$this
->
limit
;
}
else
{
return
INF
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 16:21 (23 h, 43 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
95/7e/eca5a7a1f34384590a33532bd7c4
Default Alt Text
BasicRequestTimeout.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment