Giter Site home page Giter Site logo

it9good / dorkbox_objectpool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dorkbox/objectpool

0.0 0.0 0.0 285 KB

Fast, lightweight, and compatible blocking/non-blocking/soft-reference object pool for Java 6+

License: Other

Java 7.09% Kotlin 92.91%

dorkbox_objectpool's Introduction

ObjectPool

Dorkbox Github Gitlab

This provides an ObjectPool, for providing for a safe, and fixed sized pool of objects. This is only recommended in systems were garbage collection is to be kept to a minimum, and the created objects are large.

  • This is for cross-platform use, specifically - linux 32/64, mac 32/64, and windows 32/64. Java 11+

Usage:

    val <T> pool = ObjectPool.nonBlocking(PoolObject<T>() {
        /**
         * Called when an object is returned to the pool, useful for resetting an objects state, for example.
         */
         fun onReturn(`object`: Foo) {
            object.foo = 0;
            object.bar = null;
         }
    
         /**
          * Takes an object from the pool, if there is no object available, will create a new object.
          */
          fun onTake(`object`: Foo) {
          }
    
          /**
           * @return a new object instance created by the pool.
           */
          override fun newInstance(): Foo {
             return Foo();
          }
        });


    val foo = pool.take()
    pool.put(foo)

   

Maven Info

<dependencies>
    ...
    <dependency>
      <groupId>com.dorkbox</groupId>
      <artifactId>ObjectPool</artifactId>
      <version>4.2</version>
    </dependency>
</dependencies>

Gradle Info

dependencies {
    ...
    implementation "com.dorkbox:ObjectPool:4.2"
}

License

This project is © 2020 dorkbox llc, and is distributed under the terms of the Apache v2.0 License. See file "LICENSE" for further references.

dorkbox_objectpool's People

Contributors

dorkbox avatar abinavj-familyzone avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.