@param string $functionName
@param string $workload
@param string $unique
@param int    $type         Type of job to run task as
@param int    $epoch        Time of job to run at (unix timestamp)

@return Set
770343
private function createSet($functionName, $workload, $unique = null, $type = Task::JOB_NORMAL, $epoch = 0)
    {
        if (null === $unique) {
            $unique = $this->generateUniqueId();
        }

        $task = new Task($functionName, $workload, $unique, $type, $epoch);
        $task->type = $type;
        $set = new Set();
        $set->addTask($task);

        return $set;
    }
57929
function moduleTask(taskname, depsOrFn, fn, noAutoRegister) {

    var module = this;

    if (typeof(depsOrFn) == 'string') {
      depsOrFn = [depsOrFn];
    }

    if (Array.isArray(depsOrFn)) {

      var map = [];

      depsOrFn.forEach(function (dep) {
        map.push(module.name + '-' + dep);
      });

      depsOrFn = map;

    }

    var fulltaskname = module.name + '-' + taskname;
    gulp.task(fulltaskname, depsOrFn, fn);

    if(!noAutoRegister) {
      module.tasks.push(fulltaskname);
    }

  }
646157
public function canHandle($type, JSONFunction $function, $instance = null)
    {
        if (isset($this->alias[$type])) {
            $canHandle = false;
            foreach ($this->alias[$type] as $target) {
                $canHandle = $canHandle || $this->canHandle($target, $function, $instance);
            }
            return $canHandle;
        }



        $name = $function->getName();

        if (!$this->hasFunction($type, $name)) {
            return false;
        }

        $instance = $instance == null ? $this->object : $instance;

        $args = $function->getArgs();
        /** @var \ReflectionParameter[] $parameters */
        $parameters = null;
        $this->callPreCallFunctions($type, $instance, $name, $args);

        if (isset($this->customFunctions[$type][$name])) {
            $parameters = (new \ReflectionFunction($this->customFunctions[$type][$name]))->getParameters();
            $args = array_merge([$instance], $args);
        } else if ($instance != null && isset($this->functions[$type]) && in_array($name, $this->functions[$type])) {
            $parameters = (new \ReflectionMethod($instance, $name))->getParameters();
        }
        if ($parameters === null) {
            return false;
        }

        return $this->parametersCheck($args, $parameters);
    }
941494
public function unique($type = null)
  {
    if($type === null)
    {
      return self::_createRequest(null, 'unique', HttpVerb::GET);
    }
    else
    {
      $payload = new GetByEnumPayload();
      $payload->value = $type;
      return self::_createRequest($payload, 'unique', HttpVerb::POST);
    }
  }
1286183
public function call($functionname, $params) {
        global $DB, $CFG;

         if ($this->format == 'json') {
             $formatparam = '&moodlewsrestformat=json';
             $this->serverurl->param('moodlewsrestformat','json');
         } else {
             $formatparam = ''; //to keep retro compability with old server that only support xml (they don't expect this param)
         }

        $this->serverurl->param('wstoken',$this->token);
        $this->serverurl->param('wsfunction',$functionname); //you could also use params().

        $result = download_file_content($this->serverurl->out(false), null, $params);

        //TODO MDL-22965 transform the XML result into PHP values
        if ($this->format == 'json') {
            $result = json_decode($result);
        }

        return $result;
    }
623738
public function doBackground($functionName, $workload, $unique = null)
    {
        $set = $this->createSet($functionName, $workload, $unique, Task::JOB_BACKGROUND);
        $this->runSet($set);

        return current($set->tasks);
    }
15712
public function deleteJobResult($type, $stamp = null, array $options = [])
    {
        $urlQuery = null;

        /** @var AbstractHttpRequest $request */
        $request          = $this->getRequest();
        $request->options = $options;
        $request->path    = $this->client->fullDatabasePath . static::API_PATH . '/' . $type;
        $urlQueryStr      = '';

        if ($stamp) {
            $urlQuery    = ['stamp' => $stamp];
            $urlQueryStr = $request->buildUrlQuery($urlQuery);
        }
        $request->path .= $urlQueryStr;

        $request->method = static::METHOD_DELETE;

        return $this->getReturnObject($request);
    }
1057352
public function store($export, string $filePath, string $disk = null, string $writerType = null, $diskOptions = [])
    {
        $temporaryFile = $this->temporaryFileFactory->make();

        $jobs = $this->buildExportJobs($export, $temporaryFile, $writerType);

        $jobs->push(new StoreQueuedExport(
            $temporaryFile,
            $filePath,
            $disk,
            $diskOptions
        ));

        return QueueExport::withChain($jobs->toArray())->dispatch($export, $temporaryFile, $writerType);
    }
1017347
public static function getFunctionSlot($functionName)
    {
        if (isset(self::$cacheFunctionSlots[$functionName])) {
            return self::$cacheFunctionSlots[$functionName];
        }

        $slot = self::$slot++;
        if ($slot >= self::MAX_SLOTS_NUMBER) {
            return 0;
        }

        self::$cacheFunctionSlots[$functionName] = $slot;

        return $slot;
    }
320411
public function getFunctionCache()
    {
        if (!$this->functionCache) {
            $this->functionCache = new FunctionCache($this->gatherer);
        }

        return $this->functionCache;
    }
889298
public static function create($setName, $fsOverrideGlobalPermissions = 0, $u = false, $type = self::TYPE_PUBLIC)
    {
        if (is_object($u) && $u->isRegistered()) {
            $uID = $u->getUserID();
        } else {
            if ($u) {
                $uID = $u;
            } else {
                $uID = 0;
            }
        }

        $db = Database::connection();
        $db->insert(
            "FileSets",
            array(
                'fsType' => $type,
                'uID' => $uID,
                'fsName' => $setName,
            )
        );
        $fsID = $db->lastInsertId();
        $fs = static::getByID($fsID);

        $fe = new \Concrete\Core\File\Event\FileSet($fs);
        Events::dispatch('on_file_set_add', $fe);

        return $fs;
    }
347319
public static function add($time_interval, $func, $args = array(), $persistent = true)
    {
        if ($time_interval <= 0) {
            echo new Exception("bad time_interval");
            return false;
        }

        if (!is_callable($func)) {
            echo new Exception("not callable");
            return false;
        }
        if($args === null){
            $args = array();
        }
        $real_func = function () use ($func, $args,$persistent, &$timerid) {
            call_user_func_array($func, $args);
            if($persistent === false){
                unset(self::$_tasks[$timerid]);
            }
        };
        $real_time = $time_interval*1000;
        if ($persistent === true) {
            $timerid = swoole_timer_tick($real_time, $real_func);
        } else {
            $timerid = swoole_timer_after($real_time, $real_func);
        }
        if (!isset(self::$_tasks)) {
            self::$_tasks = array();
        }
        self::$_tasks[$timerid] = array($func, (array)$args, $persistent, $real_time);
        return $timerid;
    }
844291
def _worker_fn(samples, batchify_fn, dataset=None):
    """"""
    # pylint: disable=unused-argument
    # it is required that each worker process has to fork a new MXIndexedRecordIO handle
    # preserving dataset as global variable can save tons of overhead and is safe in new process
    global _worker_dataset
    if isinstance(samples[0], (list, tuple)):
        batch = [batchify_fn([_worker_dataset[i] for i in shard]) for shard in samples]
    else:
        batch = batchify_fn([_worker_dataset[i] for i in samples])
    buf = io.BytesIO()
    ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(batch)
    return buf.getvalue()
556930
def _worker_fn(samples, batchify_fn, dataset=None):
    """"""
    # pylint: disable=unused-argument
    # it is required that each worker process has to fork a new MXIndexedRecordIO handle
    # preserving dataset as global variable can save tons of overhead and is safe in new process
    global _worker_dataset
    batch = batchify_fn([_worker_dataset[i] for i in samples])
    buf = io.BytesIO()
    ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(batch)
    return buf.getvalue()
767284
public function addFunctionAuthFunction($type, $functionName, callable $function)
    {

        $this->appendToArrayOrCallForEachAlias($type, function() use ($type, $functionName, $function){
            $this->fnAuthFunctions[$type][$functionName][] = $function;
        }, function($target) use ($functionName, $function){
            $this->addFunctionAuthFunction($target, $functionName, $function);
        });

    }
709940
public static function create($client, $jobName, $payload = null)
    {
        $longLog = new self($client, $jobName, $payload);

        return $longLog;
    }
1243429
protected function executeFunction(FunctionDescriptor $function, TransientVarsInterface $transientVars, PropertySetInterface $ps)
    {
        if (null !== $function) {
            $type = $function->getType();

            $argsOriginal = $function->getArgs();
            $args = [];

            foreach ($argsOriginal as $k => $v) {
                $translateValue = $this->getConfiguration()->getVariableResolver()->translateVariables($v, $transientVars, $ps);
                $args[$k] = $translateValue;
            }

            $provider = $this->getResolver()->getFunction($type, $args);

            if (null === $provider) {
                $this->context->setRollbackOnly();
                $errMsg = 'Не загружен провайдер для функции';
                throw new WorkflowException($errMsg);
            }

            try {
                $provider->execute($transientVars, $args, $ps);
            } catch (WorkflowException $e) {
                $this->context->setRollbackOnly();
                throw $e;
            }
        }
    }