krakjoe/ilimit

krakjoe/ilimit 扩展的集成开发环境(IDE)和静态分析辅助工具

维护者

详细信息

github.com/krakjoe/ilimit

源代码

问题

安装: 3

依赖项: 0

建议者: 0

安全: 0

星标: 70

关注者: 7

分支: 4

公开问题: 0

语言:C

dev-master 2019-11-30 07:35 UTC

This package is auto-updated.

Last update: 2024-08-29 05:18:16 UTC


README

ilimit 提供了一种方法,在执行调用时对调用可能消耗的时间和内存施加限制。

要求

  • PHP 7.1+
  • NTS
  • pthread.h

存根

此存储库包含用于 IDE 集成和静态分析支持的 PHP 文件中的方法头。

要安装,运行以下命令

composer require krakjoe/ilimit

API

namespace ilimit {
    /**
     * Call a callback while imposing limits on the time and memory that
     * the call may consume.
     *
     * @param callable $callable      The invocation to make.
     * @param array    $arguments     The list of arguments.
     * @param int      $timeout       The maximum execution time, in microseconds.
     * @param int      $maxMemory     The maximum amount of memory, in bytes.
     *                                If set to zero, no limit is imposed.
     * @param int      $checkInterval The interval between memory checks,
     *                                in microseconds. If set to zero or less,
     *                                a default interval of 100 microseconds is used.
     *
     * @return mixed Returns the return value of the callback.
     *
     * @throws Error\Runtime If timeout is not positive.
     * @throws Error\Runtime If maxMemory is negative.
     * @throws Error\System  If the system lacks necessary resources to make the call.
     * @throws Error\Timeout If the invocation exceeds the allowed time.
     * @throws Error\Memory  If the invocation exceeds the allowed memory.
     */
    function call(callable $callable, array $arguments, int $timeout, int $maxMemory = 0, int $checkInterval = 0);
}