目录
目录README.md

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",
    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.

关于
44.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号