• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Lock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Lock的典型用法代码示例。如果您正苦于以下问题:PHP Lock类的具体用法?PHP Lock怎么用?PHP Lock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Lock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: perform

 /**
  * Perform an update.
  *
  * If enabled (default) this method will send a E_USER_NOTICE about the update.
  *
  * @see setNotice()
  */
 public function perform(DataBackend $backend)
 {
     $isNotice = $this->notice;
     $lock = new Lock(self::UPDATE_LOCK);
     $lock->nonblockingExecuteOnce(function () use($backend, $isNotice) {
         $backend->update();
         if ($isNotice) {
             trigger_error("bav's bank data was updated sucessfully.", E_USER_NOTICE);
         }
     });
 }
开发者ID:bmdevel,项目名称:bav,代码行数:18,代码来源:AutomaticUpdatePlan.php


示例2: getLockForm

 /**
  * gets lightbulb form
  * @return string HTML div
  */
 public static function getLockForm()
 {
     //get all lightbulbs from db and create button for each
     $lockArray = self::get_appliances_by_type('lock');
     $form = "<div><h2>Locks</h2>";
     foreach ($lockArray as $lockItem) {
         $lock = new Lock($lockItem['applianceId']);
         $onclick = "toggleLock(this); ";
         $button = $lock->getButtonDiv($onclick);
         $form .= "<div>{$button}</div>";
     }
     $form .= "</div>";
     return $form;
 }
开发者ID:brd69125,项目名称:Smart_Home,代码行数:18,代码来源:lock.class.php


示例3: buildDataBackend

 /**
  * Builds a configured data backend.
  *
  * If configured this method would automatically install the backend. I.e. a first
  * call will take some amount of time.
  *
  * @return DataBackend
  * @throws DataBackendException
  */
 private function buildDataBackend()
 {
     $configuration = ConfigurationRegistry::getConfiguration();
     $backend = $this->makeDataBackend();
     // Installation
     if ($configuration->isAutomaticInstallation() && !$backend->isInstalled()) {
         $lock = new Lock(self::INSTALL_LOCK);
         $lock->executeOnce(function () use($backend) {
             $backend->install();
         });
     }
     // Update hook
     register_shutdown_function(array($this, "applyUpdatePlan"), $backend);
     return $backend;
 }
开发者ID:bmdevel,项目名称:bav,代码行数:24,代码来源:DataBackendContainer.php


示例4: processControlMenu

 public function processControlMenu()
 {
     if (isset($_REQUEST['main_tab'])) {
         $option = $_REQUEST['main_tab'];
         if ($option === 'lights') {
             echo Lightbulb::getLightBulbForm();
         } elseif ($option === 'locks') {
             echo Lock::getLockForm();
         } elseif ($option === 'thermostat') {
             echo Thermostat::getThermostatForm();
         } else {
             if ($option == 'lightGroups') {
                 echo LightGroup::getLightGroupForm();
             } else {
                 echo "<h3>Undefined Tab Selected</h3>";
             }
         }
         //continue with locks
         //thermostat etc.
         $this->display = FALSE;
     } else {
         $command = escapeshellcmd("python /var/www/python/killall.py");
         shell_exec($command);
         $command = escapeshellcmd("python /var/www/python/clear.py");
         shell_exec($command);
     }
 }
开发者ID:brd69125,项目名称:Smart_Home,代码行数:27,代码来源:navigation_menu.class.php


示例5: __call

 function __call($fnName, $args)
 {
     if (in_array($fnName, self::$functionExceptions)) {
         return call_user_func_array(array($this, $fnName), $args);
     }
     //get node (since all private functions require it)
     $node = $args[0] = $this->getNode($args[0]);
     if ($this->fkColumn) {
         $this->baseWhere[$this->fkColumn] = $node[$this->fkColumn];
     }
     //get foreign key to localise lock
     $lockName = 'DbTree-' . $this->table;
     if ($this->fkColumn) {
         $lockName .= '-' . $node[$this->fkColumn];
     }
     $this->__methodExists($fnName);
     Lock::req($lockName, 2);
     $this->db->db->beginTransaction();
     try {
         $return = call_user_func_array(array($this, $fnName), $args);
         $this->db->db->commit();
     } catch (Exception $e) {
         Lock::off($lockName);
         $this->db->db->rollBack();
         throw $e;
     }
     Lock::off($lockName);
     return $return;
 }
开发者ID:jstacoder,项目名称:brushfire,代码行数:29,代码来源:DbTree.php


示例6: read

 public function read()
 {
     $this->_open('r');
     $lock = new Lock($this);
     $lock->sh();
     if ($this->ttl > 0) {
         if (time() - filemtime($this->fileName) >= $this->ttl) {
             $lock->unlock();
             $this->_close();
             unlink($this->fileName);
             return false;
         }
     }
     $content = false;
     while (!feof($this->handle)) {
         $content .= fread($this->handle, 4012);
     }
     $lock->unlock();
     $this->_close();
     return $content;
 }
开发者ID:armebayelm,项目名称:thinksns-vietnam,代码行数:21,代码来源:SimpleFile.php


示例7: check_data

 /**
  *    监测是否过期 删除对用过期信息
  */
 public function check_data()
 {
     $result = Lock::all()->toArray();
     if (!empty($result)) {
         $nowtime = time();
         foreach ($result as $key => $value) {
             if ($value['time'] <= $nowtime) {
                 $this->del_data[$value['contentid']];
             }
         }
     }
 }
开发者ID:tccLaravel,项目名称:test4,代码行数:15,代码来源:Lock.php


示例8: 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;
     }
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:16,代码来源:PollingController.php


示例9: release_lock

 public static function release_lock($UID, $entity_type, $user)
 {
     // add record to lock table in order to specify that the kbit is no longer locked
     // NOTE: it is recomended to implement the lock in separated class
     if (Lock::is_locked($UID, $entity_type) == false) {
         debugLog::log("<i>[Lock::release_lock]:</i> cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked");
         return false;
     }
     if (Lock::is_locked_by_user($UID, $entity_type, $user) == false) {
         debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because it is not locked by the same user");
         return false;
     }
     $dbObj = new dbAPI();
     // disable lock records
     $query = "UPDATE CONTENT_LOCK SET ENABLED = 0 WHERE LOCKED_UID = '" . $UID . "' AND ENTITY_TYPE = '" . $entity_type . "' AND LOCK_STATUS = 'LOCKED' AND ENABLED = 1 ";
     $results = $dbObj->run_query($dbObj->db_get_contentDB(), $query);
     if ($results == false) {
         debugLog::log("<i>[Lock::release_lock]:</i>cannot release lock of [" . $entity_type . "]: " . $UID . " because of database update error");
         return false;
     }
     // add release record
     $query = "INSERT INTO CONTENT_LOCK (LOCKED_UID, ENTITY_TYPE, ENABLED, LOCK_STATUS, USER_ID, CREATION_DATE) VALUES (" . $UID . ", '" . $entity_type . "', 1, 'UNLOCKED', " . $user . ",'" . date("Y-m-d H:i:s") . "')";
     return $dbObj->run_query($dbObj->db_get_contentDB(), $query) == true;
 }
开发者ID:radjybaba,项目名称:testserver,代码行数:24,代码来源:lock.php


示例10: sleep

<?php

require "Lock.php";
$lock = Lock::factory("Dreadlock");
print "Locking...\n";
$lock->lock("ABCD");
$lock->lock("test1");
$lock->lock("test2");
$lock->lock("test3");
print "Locked.\n";
sleep(3);
print "Un-Locking...\n";
$lock->unlock("test");
print "Unlocked.\n";
sleep(3);
test:
print "Locking...\n";
$lock->lock("test");
print "Locked.\n";
sleep(3);
print "Un-Locking.\n";
$lock->unlock("test");
print "Unlocked.\n";
sleep(3);
开发者ID:kroseneg,项目名称:php-lock,代码行数:24,代码来源:test.php


示例11: Lock

<?php

/**
 * The page edit form.
 */
$page->layout = 'admin';
if (!User::require_admin()) {
    $this->redirect('/admin');
}
$lock = new Lock('Webpage', $_GET['page']);
if ($lock->exists()) {
    $page->title = i18n_get('Editing Locked');
    echo $tpl->render('admin/locked', $lock->info());
    return;
} else {
    $lock->add();
}
require_once 'apps/admin/lib/Functions.php';
$wp = new Webpage($_GET['page']);
$f = new Form('post', 'admin/edit');
$f->verify_csrf = false;
if ($f->submit()) {
    $wp->id = $_POST['id'];
    $wp->title = $_POST['title'];
    $wp->menu_title = $_POST['menu_title'];
    $wp->window_title = $_POST['window_title'];
    $wp->access = $_POST['access'];
    $wp->layout = $_POST['layout'];
    $wp->description = $_POST['description'];
    $wp->keywords = $_POST['keywords'];
    $wp->body = $_POST['body'];
开发者ID:nathanieltite,项目名称:elefant,代码行数:31,代码来源:edit.php


示例12: foreach

                    <div class="col-md-12">
                        <fieldset>
                            <legend>Locks</legend>
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Selection</th>
                                        <th>Serial</th>
                                        <th>Address</th>
                                        <th>Model</th>                                        
                                    </tr>
                                </thead>
                                <tbody id='locks'>    
                                    <?php 
$locks = Lock::searchByOwner($_SESSION['identification']);
$counter = 1;
foreach ($locks as $lock) {
    $row = "<tr>" . "<td>" . $counter++ . "</td>" . "<td><input type='radio' name='locks' onchange='showCodes(selectLock())' value='" . $lock->serial() . "'></td>" . "<td>" . $lock->serial() . "</td>" . "<td>" . $lock->address() . "</td>" . "<td>" . $lock->model() . "</td>" . "</tr>";
    echo $row;
}
?>
                                </tbody>
                            </table>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
        <div class="section">
            <div class="container">
开发者ID:smartlockmed,项目名称:smartlock,代码行数:31,代码来源:owner.php


示例13: Owner

<?php

require_once 'class/HelperOfBailiff.php';
require_once 'class/Lock.php';
require_once 'class/LockMaster.php';
require_once 'class/Owner.php';
$owner = new Owner();
$owner->setIsPresent(true);
$owner->setAgrees(false);
$lock = new Lock();
$lock->setIsLocked(true);
$helperOfBailiff = new HelperOfBailiff();
$helperOfBailiff->order($owner, $lock);
echo ' 100: Kas uks on lukus?' . $lock->getIsLocked();
开发者ID:piiskop,项目名称:pstk,代码行数:14,代码来源:calc.php


示例14: get_related_Kbits

 /**
  * returns list of terms that are related to object
  * @param {array} $object_UID    array of type array("column_name"=>'DELIVERY_BASE_ID', "value"=>5)
  * @param {string} $link_type     The link type
  * @param {string} $tableName     Table name of the relation which depends on object type, e.g. R_LD2T, R_LK2T.
  * @param  {string} $lang          The required language, if no language is selected all languages will be returned
  * @return {array:terms}                array of terms
  */
 public static function get_related_Kbits($Delivery_UID, $user)
 {
     $NEEDED = array();
     $PROVIDED = array();
     $OTHERS = array();
     // get database name
     if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == true) {
         $database_name = dbAPI::get_db_name('user');
     } else {
         $database_name = dbAPI::get_db_name('content');
     }
     $dbObj = new dbAPI();
     // get all needed and provide Kbits (as relation objects)
     $query = "SELECT * FROM R_LD2K where ENABLED = 1 AND (DELIVERY_BASE_ID = " . $Delivery_UID . ")";
     $results = $dbObj->db_select_query($database_name, $query);
     for ($i = 0; $i < count($results); $i++) {
         $curr_Kbit = Kbit::get_Kbit_details($results[$i]["KBIT_BASE_ID"], $user);
         if ($results[$i]["LINK_TYPE"] == 'NEEDED') {
             array_push($NEEDED, $curr_Kbit);
         } else {
             if ($results[$i]["LINK_TYPE"] == 'PROVIDED') {
                 array_push($PROVIDED, $curr_Kbit);
             } else {
                 array_push($OTHERS, $curr_Kbit);
             }
         }
     }
     $kbits = array("NEEDED" => $NEEDED, "PROVIDED" => $PROVIDED, "OTHERS" => $OTHERS);
     return $kbits;
 }
开发者ID:radjybaba,项目名称:testserver,代码行数:38,代码来源:relations.php


示例15: 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');
开发者ID:dabielkabuto,项目名称:eventum,代码行数:30,代码来源:process_mail_queue.php


示例16: testGetLogFileName

 /**
  * @covers Yeriomin\ConsoleApp\ConsoleApp::getLogFileName
  */
 public function testGetLogFileName()
 {
     $object1 = new ConsoleAppMock();
     $pathDefault = $this->invokeMethod($object1, 'getTempFileName', array('log'));
     $this->assertEquals(realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'consoleAppMock.log', $pathDefault);
     $testDir = '/tmp/console-app-test-dir';
     mkdir($testDir);
     $config2 = array('oneInstanceOnly' => false, 'logDir' => $testDir);
     $this->writeConfig($config2);
     Lock::getInstance()->unlock();
     $_SERVER['argv'] = self::$argvWithConfig;
     $object2 = new ConsoleAppMock();
     $pathWithDir = $this->invokeMethod($object2, 'getTempFileName', array('log'));
     $this->assertEquals(realpath($testDir) . DIRECTORY_SEPARATOR . 'consoleAppMock.log', $pathWithDir);
     $testFile = '/tmp/console-app-test-file.log';
     $config3 = array('oneInstanceOnly' => false, 'logFile' => $testFile);
     $this->writeConfig($config3);
     Lock::getInstance()->unlock();
     $object3 = new ConsoleAppMock();
     $pathWithFile = $this->invokeMethod($object3, 'getTempFileName', array('log'));
     $this->assertEquals($testFile, $pathWithFile);
     unlink($pathWithDir);
     rmdir($testDir);
 }
开发者ID:yeriomin,项目名称:console-app,代码行数:27,代码来源:ConsoleAppTest.php


示例17: trigger_error

} else {
    trigger_error("AIESEC-Customer.io-Connector is missing a config file", E_USER_ERROR);
    die;
}
// instantiate KLogger (we don't catch anything here, because we can not do anything about it)
$log = new \Katzgrau\KLogger\Logger(LOG, LOGLEVEL);
$log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector is starting.");
// try to get lock
$pid = Lock::lock($log);
// check if we got the lock
if ($pid < 1) {
    // there is a problem or another process running. Shutdown...
    $log->log(\Psr\Log\LogLevel::INFO, "AIESEC-Customer.io-Connector didn't got the lock. This instance is shutting down...");
} else {
    // we got the lock, so check that data directory is writeable
    if (!file_exists('./data') || !is_writeable('./data')) {
        die("data directory must be writeable");
    }
    //try to run the core and sync once
    try {
        $core = new Core($log);
        if ($core) {
            $core->run();
        }
    } catch (Exception $e) {
        // catch all Exception to release the lock before dying.
        $log->log(\Psr\Log\LogLevel::ERROR, "We encountered an unhandled Exception: " . $e->getMessage(), (array) $e->getTrace());
    }
    // unlock the base directory
    Lock::unlock($log);
}
开发者ID:kjschubert,项目名称:aiesec-customer.io-connector,代码行数:31,代码来源:run.php


示例18: remove_Kbit_from_delivery

 public static function remove_Kbit_from_delivery($Kbit_UID, $Delivery_UID, $link_type, $user)
 {
     if (Lock::is_locked_by_user($Delivery_UID, 'DELIVERY_BASE', $user) == false) {
         debugLog::log("<i>[delivery.php:remove_term_from_Delivery]</i> Delivery (" . $Delivery_UID . ") is not locked by the user (" . $user . ")");
         return null;
     }
     $locking_user = Lock::get_locking_user($UID, 'KBIT_BASE');
     if ($locking_user != null && $locking_user["UID"] != $user) {
         debugLog::log("<i>[delivery.php:add_Kbit_to_delivery]</i> Kbit(" . $Kbit_UID . ") is locked by other user(" . $locking_user["UID"] . ")");
         return null;
     }
     return D2KRelation::remove_D2K_relation($Kbit_UID, $Delivery_UID, $link_type, 'user');
 }
开发者ID:radjybaba,项目名称:testserver,代码行数:13,代码来源:delivery.php


示例19: 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  "));
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:31,代码来源:test.php


示例20: getTabNameForItem

 /**
  * @see CommonGLPI::getTabNameForItem()
  *
  * @param $item               CommonGLPI object
  * @param $withtemplate        (default 0)
  **/
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if ($item->isDynamic() && $item->canCreate()) {
         return Lock::getTypeName(2);
     }
     return '';
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:13,代码来源:lock.class.php



注:本文中的Lock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Log类代码示例发布时间:2022-05-23
下一篇:
PHP Location_Model类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap