public function newInstance($className)
    {

        // lock the method
        \Mutex::lock($this->mutex);

        // we're not dispatched
        $this->dispatched = false;

        // initialize the data
        $this->className = $className;

        // notify the thread
        $this->notify();

        // wait till we've dispatched the request
        while ($this->dispatched === false) {
            usleep(100);
        }

        // try to load the last created instance
        if (isset($this->instances[$last = sizeof($this->instances) - 1])) {
            $instance = $this->instances[$last];
        } else {
            throw new \Exception('Requested instance can\'t be created');
        }

        // unlock the method
        \Mutex::unlock($this->mutex);

        // return the created instance
        return $instance;
    }
public function newInstance($className)
    {

        // lock the method
        \Mutex::lock($this->mutex);

        // we're not dispatched
        $this->dispatched = false;

        // initialize the data
        $this->className = $className;

        // notify the thread
        $this->notify();

        // wait till we've dispatched the request
        while ($this->dispatched === false) {
            usleep(100);
        }

        // try to load the last created instance
        if (isset($this->instances[$last = sizeof($this->instances) - 1])) {
            $instance = $this->instances[$last];
        } else {
            throw new \Exception('Requested instance can\'t be created');
        }

        // unlock the method
        \Mutex::unlock($this->mutex);

        // return the created instance
        return $instance;
    }
public function newInstance ( $ className ) { // lock the method \ Mutex :: lock ( $ this -> mutex ) ; // we're not dispatched $ this -> dispatched = false ; // initialize the data $ this -> className = $ className ; // notify the thread $ this -> notify ( ) ; // wait till we've dispatched the request while ( $ this -> dispatched === false ) { usleep ( 100 ) ; } // try to load the last created instance if ( isset ( $ this -> instances [ $ last = sizeof ( $ this -> instances ) - 1 ] ) ) { $ instance = $ this -> instances [ $ last ] ; } else { throw new \ Exception ( 'Requested instance can\'t be created' ) ; } // unlock the method \ Mutex :: unlock ( $ this -> mutex ) ; // return the created instance return $ instance ; }
Create a new instance with the passed data.

@param string $className The fully qualified class name to return the instance for

@return object The instance itself

@throws \Exception
Create a new instance with the passed data .