https://github.com/clickermonkey/zource
A Java library for pooling expensive resources.
https://github.com/clickermonkey/zource
Last synced: 11 months ago
JSON representation
A Java library for pooling expensive resources.
- Host: GitHub
- URL: https://github.com/clickermonkey/zource
- Owner: ClickerMonkey
- License: osl-3.0
- Created: 2013-04-30T18:05:12.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-11-15T20:52:39.000Z (about 12 years ago)
- Last Synced: 2025-01-27T10:23:10.893Z (about 1 year ago)
- Language: Java
- Size: 211 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
zource
======

A Java library for pooling expensive resources.
**Features**
- A ResourcePool can return reusable resources (Resource implementation dependent) or can generate new resources if the pool doesn't have any currently available.
- A ResourcePool can automatically downsize it's number of resources if the number of unused resources meets a specified number for a specified amount of time.
**Documentation**
- [JavaDoc](http://gh.magnos.org/?r=http://clickermonkey.github.com/Zource/)
**Example**
```java
// Create a factory that creates services for handling tasks.
ResourceFactory factory = new ResourceFactory() {
public TaskService allocate() {
TaskService s = new TaskService();
s.start();
return s;
}
};
// Create a pool of services for handling tasks and populate it.
ResourcePool pool = new ResourcePool(factory);
pool.setMinCapacity(5);
pool.setMaxCapacity(10);
pool.setAllocateSize(5);
pool.setAllocateThreshold(50);
pool.setDeallocateSize(1);
pool.populate();
// Get a ready service to process a task
TaskService serve = pool.allocate();
// Create the task and give it to the service.
Task myTask = ...;
serve.addEvent(myTask);
// Empty pool and wait for all tasks to finish.
pool.empty();
```
**Builds**
- [zource-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Zource/blob/master/build/zource-1.0.0.jar?raw=true)
- [zource-src-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Zource/blob/master/build/zource-src-1.0.0.jar?raw=true) *- includes source code*
- [zource-all-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Zource/blob/master/build/zource-1.0.0.jar?raw=true) *- includes all dependencies*
- [zource-all-src-1.0.0.jar](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Zource/blob/master/build/zource-src-1.0.0.jar?raw=true) *- includes all dependencies and source code*
**Projects using zource:**
- [taskaroo](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Taskaroo)
- [falcon](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Falcon)
**Dependencies**
- [curity](http://gh.magnos.org/?r=https://github.com/ClickerMonkey/Curity)