It is not uncommon for a machine that is running heterogeneous tasks to have different tasks take vastly different amounts of resources. Some may use a lot of ram but no cpu, etc. Resource limit is a generic way to limit the amount of resources the system can use assuming they can be statically defined for the task.
In our case resources are represented by an integer and as long as subtracting that number from the system's resources returns a result above or equal to zero we assume that those resources are available.
A resource map can contain many entries of keyword->integer.
At manager creation time a similar map is provided indicating the initial state.
It is not uncommon for a machine that is running heterogeneous tasks to have different tasks take vastly different amounts of resources. Some may use a lot of ram but no cpu, etc. Resource limit is a generic way to limit the amount of resources the system can use assuming they can be statically defined for the task. In our case resources are represented by an integer and as long as subtracting that number from the system's resources returns a result above or equal to zero we assume that those resources are available. A resource map can contain many entries of keyword->integer. At manager creation time a similar map is provided indicating the initial state.
(default-resource-map &
{:keys [unavailable-system-mem]
:or {unavailable-system-mem (gigabyte->megabyte 1)}})
(release-resources! mgr resource-map)
nonblocking returns resources to the source
nonblocking returns resources to the source
(request-resources! mgr resource-map timeout-ms)
potentially blocking call, returns when resources can be satisfied
potentially blocking call, returns when resources can be satisfied
(resource-manager {:keys [initial-resources]
:or {initial-resources (default-resource-map)}})
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close