本文整理汇总了PHP中Lock::release方法的典型用法代码示例。如果您正苦于以下问题:PHP Lock::release方法的具体用法?PHP Lock::release怎么用?PHP Lock::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lock
的用法示例。
在下文中一共展示了Lock::release方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchRecord
public function fetchRecord()
{
try {
$lock = Lock::acquire('getPendingRecord');
if (($r = $this->getPendingRecord()) == NULL) {
throw new fExpectedException('No pending record.');
}
$p = $r->getProblem();
$r->setJudgeStatus(JudgeStatus::WAITING);
$r->store();
Lock::release($lock);
echo json_encode(array('id' => $r->getId(), 'problem_id' => $p->getId(), 'code_language' => $r->getLanguageName(), 'code' => base64_encode($r->getSubmitCode()), 'memoryLimit' => $p->getMemoryLimit(), 'timeLimit' => $p->getTimeLimit(), 'caseScore' => $p->getCaseScore(), 'caseCount' => $p->getCaseCount(), 'Timestamp' => $p->getLastModified()), JSON_NUMERIC_CHECK);
} catch (fException $e) {
echo -1;
}
}
示例2: foreach
} else {
foreach (array_keys($config) as $key) {
if (isset($_GET[$key])) {
$config[$key] = $_GET[$key];
}
}
}
return $config;
}
$config = getParams();
// if requested, clear the lock
if ($config['fix-lock']) {
if (Lock::release('process_mail_queue')) {
echo "The lock file was removed successfully.\n";
}
exit(0);
}
if (!Lock::acquire('process_mail_queue')) {
$pid = Lock::getProcessID('process_mail_queue');
fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
exit(1);
}
// handle only pending emails
$limit = 50;
Mail_Queue::send('pending', $limit);
// handle emails that we tried to send before, but an error happened...
$limit = 50;
Mail_Queue::send('error', $limit);
Lock::release('process_mail_queue');
示例3: ini_set
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
// | GNU General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to: |
// | |
// | Free Software Foundation, Inc. |
// | 51 Franklin Street, Suite 330 |
// | Boston, MA 02110-1301, USA. |
// +----------------------------------------------------------------------+
// | Authors: Bryan Alsdorf <balsdorf@gmail.com> |
// +----------------------------------------------------------------------+
ini_set('memory_limit', '1024M');
require_once dirname(__FILE__) . '/../init.php';
// if requested, clear the lock
if (in_array('--fix-lock', $argv)) {
if (Lock::release('truncate_mail_queue')) {
echo "The lock file was removed successfully.\n";
}
exit(0);
}
if (!Lock::acquire('truncate_mail_queue')) {
$pid = Lock::getProcessID('truncate_mail_queue');
fwrite(STDERR, "ERROR: There is already a process (pid={$pid}) of this script running.");
fwrite(STDERR, "If this is not accurate, you may fix it by running this script with '--fix-lock' as the only parameter.\n");
exit(1);
}
Mail_Queue::truncate();
Lock::release('truncate_mail_queue');
示例4: foreach
$triggered_issues[] = $issue;
}
}
if (count($issues) > 0) {
foreach ($issues as $issue) {
if (Reminder::isDebug()) {
echo " - Processing issue '" . $issue . "'\n";
}
// only perform one action per issue id
if (in_array($issue, $triggered_issues)) {
if (Reminder::isDebug()) {
echo " - Ignoring issue '" . $issue . "' because it was found in the list of already triggered issues\n";
}
continue;
}
$triggered_issues[] = $issue;
if (Reminder::isDebug()) {
echo " - Triggered Action '" . $action['rma_title'] . "' for issue #" . $issue . "\n";
}
Reminder_Action::perform($issue, $reminder, $action);
}
} else {
if (Reminder::isDebug()) {
echo " - No triggered issues for action '" . $action['rma_title'] . "'\n";
}
}
}
}
// release the lock
Lock::release('check_reminders');
示例5: assertEquals
assertEquals("ș'aibă", FlexStringUtil::placeAccent("șaibă", 2, 'a'));
assertEquals("ș'aibă", FlexStringUtil::placeAccent("șaibă", 3, 'a'));
assertEquals("șa'ibă", FlexStringUtil::placeAccent("șaibă", 2, 'i'));
assertEquals("șa'ibă", FlexStringUtil::placeAccent("șaibă", 3, 'i'));
assertEquals("unfuckingbelievable", FlexStringUtil::insert("unbelievable", "fucking", 2));
assertEquals("abcdef", FlexStringUtil::insert("cdef", "ab", 0));
assertEquals("abcdef", FlexStringUtil::insert("abcd", "ef", 4));
assertEquals('mamă ', AdminStringUtil::padRight('mamă', 10));
assertEquals('mama ', AdminStringUtil::padRight('mama', 10));
assertEquals('ăâîșț ', AdminStringUtil::padRight('ăâîșț', 8));
assertEquals('ăâîșț', AdminStringUtil::padRight('ăâîșț', 5));
assertEquals('ăâîșț', AdminStringUtil::padRight('ăâîșț', 3));
assertEqualArrays(array('c', 'a', 'r'), AdminStringUtil::unicodeExplode('car'));
assertEqualArrays(array('ă', 'a', 'â', 'ș', 'ț'), AdminStringUtil::unicodeExplode('ăaâșț'));
assertEqualArrays(array(1, 5, 10), util_intersectArrays(array(1, 3, 5, 7, 9, 10), array(1, 2, 4, 5, 6, 8, 10)));
assertEqualArrays(array(), util_intersectArrays(array(2, 4, 6, 8), array(1, 3, 5, 7)));
assert(!Lock::release('test'));
assert(!Lock::exists('test'));
assert(Lock::acquire('test'));
assert(Lock::exists('test'));
assert(!Lock::acquire('test'));
assert(Lock::release('test'));
assert(!Lock::exists('test'));
assert(!Lock::release('test'));
assertEquals(0, util_findSnippet(array(array(1, 2, 10))));
assertEquals(1, util_findSnippet(array(array(1, 2, 10), array(5, 6, 9))));
assertEquals(2, util_findSnippet(array(array(1, 2, 10), array(5, 6, 8))));
assertEquals(4, util_findSnippet(array(array(1, 2, 10), array(6, 20), array(8, 15))));
assertEquals('$abc$ @def@', AdminStringUtil::formatLexem('$abc$ @def@'));
// This is intentional -- lexem formatting is very lenient.
assertEquals("m'amă m'are", AdminStringUtil::formatLexem("m'am~a máre "));
示例6: cleanup_lock
function cleanup_lock()
{
global $account_id;
Lock::release('download_emails_' . $account_id);
}
示例7: ini_set
<?php
/*
* This file is part of the Eventum (Issue Tracking System) package.
*
* @copyright (c) Eventum Team
* @license GNU General Public License, version 2 or later (GPL-2+)
*
* For the full copyright and license information,
* please see the COPYING and AUTHORS files
* that were distributed with this source code.
*/
ini_set('memory_limit', '1024M');
require_once __DIR__ . '/../init.php';
// if requested, clear the lock
if (in_array('--fix-lock', $argv)) {
Lock::release('irc_bot');
echo "The lock file was removed successfully.\n";
exit;
}
if (in_array('--check-process', $argv)) {
$check = true;
} else {
$check = false;
}
// NB: must require this in global context
// otherise $SMARTIRC_nreplycodes from defines.php is not initialized
require_once 'Net/SmartIRC/defines.php';
try {
$bot = new Eventum_Bot();
} catch (InvalidArgumentException $e) {
error_log($e->getMessage());
示例8: unlock
public function unlock()
{
Lock::release($this->config['lock']);
}
示例9: Lock
<?php
/**
*
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require __DIR__ . '/../classes/Lock.class.php';
$lock = new Lock('test');
if ($lock->exists()) {
die("Lock '" . $lock->getId() . "' exists\n");
}
echo "Acquire lock...\n";
$lock->acquire();
echo "Doing smth for 10 seconds...\n";
echo "During this time, another instance of this script will not run\n";
sleep(10);
echo "Releasing lock...\n";
echo $lock->release();
示例10: imap_expunge
echo "The lock file was removed successfully.\n";
exit;
}
// check if there is another instance of this script already running
if (!Lock::acquire('download_emails_' . $account_id)) {
if ($type == 'cli') {
echo "Error: Another instance of the script is still running for the specified account. " . "If this is not accurate, you may fix it by running this script with '--fix-lock' " . "as the 4th parameter or you may unlock ALL accounts by running this script with '--fix-lock' " . "as the only parameter.\n";
} else {
echo "Error: Another instance of the script is still running for the specified account. " . "If this is not accurate, you may fix it by running this script with 'fix-lock=1' " . "in the query string or you may unlock ALL accounts by running this script with 'fix-lock=1' " . "as the only parameter.<br />\n";
}
exit;
}
$account = Email_Account::getDetails($account_id);
$mbox = Support::connectEmailServer($account);
if ($mbox == false) {
echo "Error: Could not connect to the email server. Please verify your email account settings and try again.\n";
Lock::release('download_emails_' . $account_id);
exit;
} else {
$total_emails = Support::getTotalEmails($mbox);
if ($total_emails > 0) {
for ($i = 1; $i <= $total_emails; $i++) {
Support::getEmailInfo($mbox, $account, $i);
}
}
imap_expunge($mbox);
Support::clearErrors();
}
// clear the lock
Lock::release('download_emails_' . $account_id);
示例11: removeProcessFile
/**
* Clears the lock file for the next time this script runs again.
*
* @access public
* @return void
*/
function removeProcessFile()
{
Lock::release('process_mail_queue');
}
示例12: round
}
}
if (++$defsSeen % 10000 == 0) {
$runTime = DebugInfo::getRunningTimeInMillis() / 1000;
$speed = round($defsSeen / $runTime);
log_scriptLog("{$defsSeen} of {$numDefs} definitions indexed ({$speed} defs/sec). " . "Word map has " . count($ifMap) . " entries. " . "Memory used: " . round(memory_get_usage() / 1048576, 1) . " MB.");
}
}
fclose($handle);
log_scriptLog("{$defsSeen} of {$numDefs} definitions indexed.");
log_scriptLog("Index size: {$indexSize} entries.");
OS::executeAndAssert("chmod 666 {$fileName}");
log_scriptLog("Importing file {$fileName} into table FullTextIndex");
db_executeFromOS("load data local infile '{$fileName}' into table FullTextIndex");
util_deleteFile($fileName);
if (!Lock::release(LOCK_FULL_TEXT_INDEX)) {
log_scriptLog('WARNING: could not release lock!');
}
log_scriptLog('rebuildFullTextIndex.php completed successfully ' . '(against all odds)');
/***************************************************************************/
function extractWords($text)
{
$alphabet = 'abcdefghijklmnopqrstuvwxyzăâîșț';
$text = mb_strtolower($text);
$text = AdminStringUtil::removeAccents($text);
$result = array();
$currentWord = '';
$chars = AdminStringUtil::unicodeExplode($text);
foreach ($chars as $c) {
if (strpos($alphabet, $c) !== false) {
$currentWord .= $c;