Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krakjoe/ilimit
Limit time and memory consumption of individual calls
https://github.com/krakjoe/ilimit
Last synced: 3 months ago
JSON representation
Limit time and memory consumption of individual calls
- Host: GitHub
- URL: https://github.com/krakjoe/ilimit
- Owner: krakjoe
- License: other
- Created: 2019-11-10T06:38:27.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-30T07:35:34.000Z (almost 5 years ago)
- Last Synced: 2024-05-28T01:07:53.422Z (6 months ago)
- Language: C
- Homepage:
- Size: 55.7 KB
- Stars: 70
- Watchers: 7
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ilimit
======`ilimit` provides a method to execute a call while imposing limits on the time and memory that the call may consume.
Requirements
============* PHP 7.1+
* NTS
* pthread.h
Stubs
=====This repository includes PHP files with method headers for IDE integration and
static analysis support.To install, run the following command:
```
composer require krakjoe/ilimit
```API
===```php
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);
}
```