本文整理汇总了PHP中sem_remove函数的典型用法代码示例。如果您正苦于以下问题:PHP sem_remove函数的具体用法?PHP sem_remove怎么用?PHP sem_remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sem_remove函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unlock
/**
* @return bool
*/
public function unlock()
{
$released = sem_release($this->lock);
sem_remove($this->lock);
$this->lock = null;
return $released;
}
示例2: testfailRemovingSemaphore
/**
* Tests removing semaphore fails.
*
* @test
* @expectedException bandwidthThrottle\tokenBucket\storage\StorageException
* @expectedExceptionMessage Could not remove semaphore.
*/
public function testfailRemovingSemaphore()
{
$key = ftok(__FILE__, "a");
$storage = new IPCStorage($key);
sem_remove(sem_get($key));
@$storage->remove();
}
示例3: store
public static function store($key, $value)
{
self::getHandle();
if (!shm_put_var(self::$handle, self::getVarKey($key), $value)) {
sem_remove(self::$semaphore);
shm_remove(self::$handle);
die('couldn\'t write to shared memory.');
}
self::release();
}
示例4: drop
function drop($key)
{
try {
return sem_remove($this->locks[$key]);
} catch (ExecutionContextException $e) {
unset($this->locks[$key]);
// already race-removed
return false;
}
}
示例5: remove
public function remove()
{
if (!shm_remove($this->memory)) {
throw new StorageException("Could not release shared memory.");
}
$this->memory = null;
if (!sem_remove($this->semaphore)) {
throw new StorageException("Could not remove semaphore.");
}
$this->semaphore = null;
}
示例6: drop
public function drop($key)
{
if (isset($this->pool[$key])) {
try {
return sem_remove($this->pool[$key]);
} catch (BaseException $e) {
unset($this->pool[$key]);
// already race-removed
return false;
}
}
return null;
}
示例7: delete
function delete()
{
if ($this->shm) {
sem_acquire($this->sem());
try {
$this->shm->delete();
sem_release($this->sem());
} catch (Exception $e) {
sem_release($this->sem());
}
}
$this->logger->debug(sprintf("Delete semaphore (key: 0x%08x)", $this->semKey));
sem_remove($this->sem());
if (isset($e)) {
throw $e;
}
}
示例8: setUniqueValue
function setUniqueValue($value, $user, $userid = 0)
{
$conn = create_db_connection();
$key = md5($value . ":unique-value:" . $user);
$sem = 0;
if (function_exists("sem_get")) {
$sem = sem_get(ftok(realpath("config/upload.php"), 'R'));
sem_acquire($sem);
}
$conn->openselect("select * from " . getUserConfig("dbprefix") . "uniquevalues where md5='" . $key . "' and user='" . $conn->escape($user) . "' and userid=0" . intval($userid));
if ($conn->eof()) {
$conn->execute("insert into " . getUserConfig("dbprefix") . "uniquevalues(md5,util,user,userid) values('" . $conn->escape($key) . "','" . $conn->escape($value) . "','" . $conn->escape($user) . "',0" . intval($userid) . ")");
} else {
resetUniqueValue($key, $value, $user, $userid);
}
if ($sem) {
sem_release($sem);
sem_remove($sem);
}
$conn->close();
return $key;
}
示例9: release
/**
* Release the lock
*
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function release()
{
if (!$this->isAcquired) {
return TRUE;
}
$success = TRUE;
switch ($this->method) {
case 'simple':
if (unlink($this->resource) == FALSE) {
$success = FALSE;
}
break;
case 'flock':
if (flock($this->filepointer, LOCK_UN) == FALSE) {
$success = FALSE;
}
fclose($this->filepointer);
unlink($this->resource);
break;
case 'semaphore':
if (@sem_release($this->resource)) {
sem_remove($this->resource);
} else {
$success = FALSE;
}
break;
case 'disable':
$success = FALSE;
break;
}
$this->isAcquired = FALSE;
return $success;
}
示例10: destroy
/**
* Destroys the resource associated with the lock
*
* @return void
*/
public function destroy()
{
if ($this->resource) {
sem_remove($this->resource);
@unlink($this->filePath);
}
}
示例11: unlock
public static function unlock($semId)
{
sem_release($semId);
sem_remove($semId);
}
示例12: destroy
/**
* Force release
*/
public function destroy()
{
sem_remove($this->__mutex);
shm_remove($this->__shm);
}
示例13: __destruct
public function __destruct()
{
foreach ($this->activeMegaListeners as $listener) {
$this->megaApi->removeListener($listener);
}
foreach ($this->activeMegaRequestListeners as $listener) {
$this->megaApi->removeRequestListener($listener);
}
foreach ($this->activeMegaTransferListeners as $listener) {
$this->megaApi->removeTransferListener($listener);
}
foreach ($this->activeMegaGlobalListeners as $listener) {
$this->megaApi->removeGlobalListener($listener);
}
sem_remove($this->semaphore);
}
示例14: release
/**
* Release the lock
*
* @return boolean Returns TRUE on success or FALSE on failure
*/
public function release()
{
if (!$this->isAcquired) {
return TRUE;
}
$success = TRUE;
switch ($this->method) {
case 'flock':
if (flock($this->filepointer, LOCK_UN) == FALSE) {
$success = FALSE;
}
fclose($this->filepointer);
//if (\TYPO3\CMS\Core\Utility\GeneralUtility::isAllowedAbsPath($this->resource) && \TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->resource, PATH_site . 'typo3temp'.DIRECTORY_SEPARATOR.'extbase_hijax'.DIRECTORY_SEPARATOR.'locks'.DIRECTORY_SEPARATOR)) {
// TODO: add a scheduler task to remove old lock files
// unlink($this->resource);
//}
break;
case 'semaphore':
if (@sem_release($this->resource)) {
sem_remove($this->resource);
} else {
$success = FALSE;
}
break;
case 'disable':
$success = FALSE;
break;
}
$this->isAcquired = FALSE;
return $success;
}
示例15: __release
/**
* Release all resource after process end
* Call by destruct
*
* @return void
*/
protected function __release()
{
// release global space for vars
$this->global->remove();
// release shared space for vars
$this->shared->remove();
// remove mutex for lock
@sem_remove($this->mutex);
}