Exemplo n.º 1
0
 /**
  * @throws \Axvf\Threadable\Exceptions\NoSuchProcessException
  */
 public function testStart()
 {
     $Class = $this->getAbstraction();
     $Class->spawnThread();
     $this->assertGreaterThan(1, \Axvf\Threadable\ProcessControl::getProcessIdsOfThreadKey($Class->getThreadKey())[0]);
     $this->assertTrue(Redis::client()->exists($Class->getThreadKey()));
     $Class->killThread();
     $this->assertFalse(Redis::client()->exists($Class->getThreadKey()));
 }
Exemplo n.º 2
0
 /**
  * @return \Redis
  */
 protected function getRedisInstance()
 {
     return Redis::client();
 }
Exemplo n.º 3
0
<?php

namespace Axvf\Threadable;

use Axvf\Redis\Redis;
use Axvf\Threadable\Exceptions\NoSuchThreadableObjectException;
$Autoloader = dirname(__FILE__) . '/../../../autoload.php';
require_once $Autoloader;
/**
 * @var ThreadableInterface $ThreadableObject
 */
$ThreadableObject = Redis::client()->get(CommandParse::getCurrentThreadKey());
/**
 * Try a second time to get the object from redis if
 *  the object isn't an instance of ThreadableInterface
 */
if (!$ThreadableObject instanceof ThreadableInterface) {
    sleep(1);
    $ThreadableObject = Redis::client()->get(CommandParse::getCurrentThreadKey());
    if (!$ThreadableObject instanceof ThreadableInterface) {
        throw new NoSuchThreadableObjectException($ThreadableObject);
    }
}
$ThreadableObject->start();
Exemplo n.º 4
0
 /**
  * @expectedException Axvf\Redis\Exceptions\RedisUnsubscribeException
  */
 public function testUnsubscribe()
 {
     Redis::client()->unsubscribe();
 }