public function hook($hookName, $handler = null, $override = false)
    {
        if (is_callable($handler) && is_string($hookName)) {
            if (in_array($hookName, self::$hooks)) {
                if (!isset($this->handlers[$hookName])) {
                    $this->handlers[$hookName] = [];
                }
                if ($override) {
                    $this->handlers[$hookName] = [$handler];
                } else {
                    array_push($this->handlers[$hookName], $handler);
                }
            } else {
                throw new TaskBalancerException("Don't support hooks `$hookName`.");
            }
        } elseif (is_array($hookName)) {
            if (is_bool($handler) && $handler) {
                $this->handlers = [];
            }
            foreach ($hookName as $k => $v) {
                $this->hook($k, $v, false);
            }
        }
    }