Pool

1.0.0

A generic object pool implementation for Swift that works on macOS and Linux.
reswifq/pool

What's New

Pool v1.0.0

2017-02-26T15:13:54Z

First release.

Pool

Swift Build Status Code Coverage

A generic object pool implementation for Swift that works on macOS and Linux.

🏁 Getting Started

Import Pool into your project using Swift Package Manager:

import PackageDescription

let package = Package(
    name: "YourProject",
    targets: [],
    dependencies: [
        .Package(url: "https://github.com/reswifq/pool.git", majorVersion: 1)
    ]
)

Create a pool of elements:

let pool = Pool(maxElementCount: 10) { 
	return "I am a pool element"
}

Draw an element from the pool:

let element = try pool.draw()

Do something with it:

print(element) // "I am a pool element"

Put it back in the pool, so it can be reused:

pool.release(element)

Optionally you can wait until it has been released:

pool.release(element) {
	print("element has been released and it's ready to be drawn again")
}

🔧 Compatibility

This package has been tested on macOS and Ubuntu.

📖 License

Created by Valerio Mazzeo.

Copyright © 2017 VMLabs Limited. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

See the GNU Lesser General Public License for more details.

Description

  • Swift Tools 3.1.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat Mar 16 2024 08:23:52 GMT-0900 (Hawaii-Aleutian Daylight Time)