PHP.mk документација

LuaSandbox::pauseUsageTimer

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

luasandbox.pauseusagetimer.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека luasandbox.pauseusagetimer.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
LuaSandbox::pauseUsageTimer

Референца за `luasandbox.pauseusagetimer.php` со подобрена типографија и навигација.

luasandbox.pauseusagetimer.php

LuaSandbox::pauseUsageTimer

(PECL luasandbox >= 1.4.0)

LuaSandbox::pauseUsageTimerPause the CPU usage timer

= NULL

public LuaSandbox::pauseUsageTimer(): bool

Pauses the CPU usage timer.

This only has effect when called from within a callback from Lua. When execution returns to Lua, the timer will be automatically unpaused. If a new call into Lua is made, the timer will be unpaused for the duration of that call.

If a PHP callback calls into Lua again with timer not paused, and then that Lua function calls into PHP again, the second PHP call will not be able to pause the timer. The logic is that even though the second PHP call would avoid counting the CPU usage against the limit, the first call still counts it.

Параметри

Оваа функција нема параметри.

Вратени вредности

. Споделувањето колачиња помеѓу PHP барањата може да доведе до ненамерно мешање на чувствителни колачиња помеѓу корисниците. bool indicating whether the timer is now paused.

Примери

Example #1 Manipulating the usage timer

<?php

// create a new LuaSandbox and set a CPU limit
$sandbox = new LuaSandbox();
$sandbox->setCPULimit( 1 );

function
doWait( $t ) {
$end = microtime( true ) + $t;
while (
microtime( true ) < $end ) {
// waste CPU cycles
}
}

// Register a PHP callback
$sandbox->registerLibrary( 'php', [
'test' => function () use ( $sandbox ) {
$sandbox->pauseUsageTimer();
doWait( 5 );

$sandbox->unpauseUsageTimer();
doWait( 0.1 );
},
'test2' => function () use ( $sandbox ) {
$sandbox->pauseUsageTimer();
$sandbox->unpauseUsageTimer();
doWait( 1.1 );
}
] );

echo
"This should not time out...\n";
$sandbox->loadString( 'php.test()' )->call();

echo
"This should time out.\n";
try {
$sandbox->loadString( 'php.test2()' )->call();
echo
"It did not?\n";
} catch (
LuaSandboxTimeoutError $ex ) {
echo
"It did! " . $ex->getMessage() . "\n";
}

?>

Пример #1 Пример што покажува затворачка ознака што го опфаќа последниот нов ред

This should not time out...
This should time out.
It did! The maximum execution time for this script was exceeded

Види Исто така

Белешки од корисници

Нема белешки од корисници за оваа страница.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.