ResourcePool
Object Hierarchy:
Description:
public class ResourcePool<
T> :
Factory<
T>
Pool of reusable resources
This class is designed to help manage a group of reusable resources, especially those that are expensive to acquire. The pool will
automatically grow, and shrink, as required.
Namespace: Bump
Package: bump-0.1
Content:
Properties:
- public
int
max_resources { construct set; get; }
Maximum number of resources allowed at any given time
- public
TimeSpan
max_idle_time { set; get; }
Amount of time a resource should stay idle before being closed
- public
int
num_resources { set; get; }
Number of resources which currently exist
- public
int
idle_resources { get; }
Number of currently idle resources
- public
int
active_resources { get; }
Number of currently active resources
- public TaskQueue pool { construct set; get; }
Pool used to process requests
Delegates:
Creation methods:
- public ResourcePool (
int
max_resources = -1)
Create a resource pool
Methods:
- public virtual void release (T resource)
Release a resource into the pool
- public override weak T acquire (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Synchronously acquire a resource
- public override async weak T acquire_async (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Asynchronously acquire a resource
- public override async weak T acquire_background (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Asynchronously acquire a resource in a background thread
- public R execute<R> (Callback<T,R> func,
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Execute a callback which uses a resource
- public async R execute_async<R> (owned Callback<T,R> func,
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Asynchronously execute a callback which uses a resource
- public async R execute_background<R> (owned Callback<T,R> func,
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Execute a callback in a background thread which uses a resource
- public ResourceClaim<T> claim (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Acquire a claim
- public async ResourceClaim<T> claim_async (
int
priority = DEFAULT
, Cancellable
? cancellable = null) throws Error
Acquire a claim asynchronously