public function defineTask($name, $object)
    {
        $options = static::getOptions();
        $debug = @$options['debug'] === true;

        if ($this->started)
            throw new \Exception("Define tasks before start()ing the daemon not after");

        if (! $object instanceof AbstractTask)
            throw new \Exception("Task must implement AbstractTask");

        $object->setDaemon($this);
        $this->tasks[$name] = $object;

        if ($debug)
            echo "==> Task defined: $name" . PHP_EOL;

        return $this;
    }