Pool

A generic object pool implementation for Swift that works on macOS and Linux.
🏁 Getting Started
import PackageDescription
let package = Package(
name: "YourProject",
products: [
.executable(name: "YourProject", targets: ["YourProject"])
],
dependencies: [
.package(url: "https://github.com/reswifq/pool.git", .upToNextMajor(from: "1.3.0"))
],
targets: [
.target(name: "YourProject", dependencies: ["Pool"])
]
)
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.
Pool
A generic object pool implementation for Swift that works on macOS and Linux.
🏁 Getting Started
Import Pool into your project using Swift Package Manager:
Create a pool of elements:
Draw an element from the pool:
Do something with it:
Put it back in the pool, so it can be reused:
Optionally you can wait until it has been released:
🔧 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.