ResourcePool
Object Hierarchy:
Bump.ResourcePool
Bump.ResourcePool
Bump.ResourcePool
Bump.Factory
Bump.Factory
Bump.Factory->Bump.ResourcePool
GLib.Object
GLib.Object
GLib.Object->Bump.Factory
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.
Content:
Properties:
public int active_resources { get ; }
Number of currently active resources
public int idle_resources { get ; }
Number of currently idle resources
public TimeSpan max_idle_time { get ; set ; }
Amount of time a resource should stay idle before being closed
public int max_resources { get ; construct ; }
Maximum number of resources allowed at any given time
public int num_resources { get ; }
Number of resources which currently exist
public TaskQueue pool { get ; construct ; }
Pool used to process requests
Delegates:
public delegate R Callback <T ,R > (T resource) throws Error
Creation methods:
public ResourcePool (int max_resources = -1 )
Create a resource pool
Methods:
public override unowned T acquire (int priority = DEFAULT , Cancellable ? cancellable = null ) throws Error
Synchronously acquire a resource
public override async unowned T acquire_async (int priority = DEFAULT , Cancellable ? cancellable = null ) throws Error
Asynchronously acquire a resource
public override async unowned T acquire_background (int priority = DEFAULT , Cancellable ? cancellable = null ) throws Error
Asynchronously acquire a resource in a background thread
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
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 virtual void release (T resource)
Release a resource into the pool
Inherited Members:
All known members inherited from class Bump.Factory
All known members inherited from class GLib.Object
@get
@new
@ref
@set
add_toggle_ref
add_weak_pointer
bind_property
connect
constructed
disconnect
dispose
dup_data
dup_qdata
force_floating
freeze_notify
get_class
get_data
get_property
get_qdata
get_type
getv
interface_find_property
interface_install_property
interface_list_properties
is_floating
new_valist
new_with_properties
newv
notify
notify_property
ref_count
ref_sink
remove_toggle_ref
remove_weak_pointer
replace_data
replace_qdata
set_data
set_data_full
set_property
set_qdata
set_qdata_full
set_valist
setv
steal_data
steal_qdata
thaw_notify
unref
watch_closure
weak_ref
weak_unref