public function attach(Task $task, $task_name = null)
    {
        if (is_null($task_name)) {
            $task_name = count($this->tasks);
        }
        $this->tasks[$task_name] = $task;
        curl_multi_add_handle($this->curl, $task->createCurl());
        $deferred = new Deferred();
        $this->deferred[$task_name] = $deferred;

        return $deferred->promise();
    }
public function attach(Task $task, $task_name = null)
    {
        if (is_null($task_name)) {
            $task_name = count($this->tasks);
        }
        $this->tasks[$task_name] = $task;
        curl_multi_add_handle($this->curl, $task->createCurl());
        $deferred = new Deferred();
        $this->deferred[$task_name] = $deferred;

        return $deferred->promise();
    }
public function attach ( Task $ task , $ task_name = null ) { if ( is_null ( $ task_name ) ) { $ task_name = count ( $ this -> tasks ) ; } $ this -> tasks [ $ task_name ] = $ task ; curl_multi_add_handle ( $ this -> curl , $ task -> createCurl ( ) ) ; $ deferred = new Deferred ( ) ; $ this -> deferred [ $ task_name ] = $ deferred ; return $ deferred -> promise ( ) ; }
add new task and return a promise

@param Task $task
@param null $task_name
@return \React\Promise\PromiseInterface
add new task and return a promise