Login   Register  
PHP Classes
elePHPant
Icontem

File: docs/api/files/Communication/Driver/ADriver.php.txt

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of AlexanderC  >  Threadator  >  docs/api/files/Communication/Driver/ADriver.php.txt  >  Download  
File: docs/api/files/Communication/Driver/ADriver.php.txt
Role: Documentation
Content type: text/plain
Description: Documentation
Class: Threadator
Create threads and send messages between them
Author: By
Last change:
Date: 8 months ago
Size: 1,239 bytes
 

Contents

Class file image Download
<?php
/**
 * @author AlexanderC <self@alexanderc.me>
 * @date 4/8/14
 * @time 12:01 AM
 */

namespace Threadator\Communication\Driver;


abstract class ADriver
{
    /**
     * @var string
     */
    protected $identifier;

    /**
     * @param string $identifier
     */
    public function __construct($identifier)
    {
        $this->identifier = (string) $identifier;

        $this->init();
    }

    /**
     * @return void
     */
    public function __clone()
    {
        $this->init();
    }

    /**
     * @return string
     */
    public function getIdentifier()
    {
        return $this->identifier;
    }

    /**
     * @return void
     */
    abstract protected function init();

    /**
     * @param int $key
     * @param mixed $message
     * @return bool
     */
    abstract public function send($key, $message);

    /**
     * Try to get message, but do not block
     *
     * @param int $key
     * @param mixed $message
     * @return bool
     */
    abstract public function touch($key, & $message);

    /**
     * Block until the first message arrives
     *
     * @param int $key
     * @param mixed $message
     * @return bool
     */
    abstract public function receive($key, & $message);
}