gets an object from the pool

@return the pooled object
550905
public T get() {
        T object;

        while (true) {
            // 1. get the next free object
            int p = m_put.get();
            int g = m_get.get();
            if (g >= p) {
                // get index hits the put index, implying empty pool
                if (p >= LIMIT) {
                    // put pointer wrapped around. rewind both indexes.
                    m_get.set(0);
                    m_put.set(0);
                }
                return null;
            }

            // 2. conquer this cell by incrementing the get index
            if (!m_get.compareAndSet(g, g + 1)) {
                // some other thread got here first. try again.
                continue;
            }

            // 3. retrieve the object at the get index
            int index = g % m_arraySize;
            AtomicReference<T> reference = m_array[index];
            object = reference.get();
            if (object == null) {
                // getting here is rare. it happens when:
                // 1. put() is called on an empty pool (p==g)
                // 2. put() increments the put pointer (p==g+1)
                // 3. get() is called and finds g < p
                // 4. get() takes the object at g (which is null)
                // 5. put() puts the object at g
                continue;
            }

            // 4. change the reference to null so no other get() takes the
            // same element, and no other put() replaces it with another.
            if (reference.compareAndSet(object, null)) {
                return object;
            }

            // getting here is rare. the object that was supposedly conquered
            // locally was either replaced by a different object or replaced
            // with null, in the same cell.
        }
    }
1081768
public ConnectionPool getPool(String poolName)
            throws ConnectionPoolNotFoundException {
        ConnectionPool connectionPool = null;

        try {
            if (h_ConnectionPools.containsKey(poolName)) {
                connectionPool = h_ConnectionPools.get(poolName);
            } else {
                // Error: pool was never initialized or name could not be found
                throw new ConnectionPoolNotFoundException("Connection pool "
                        + "not found: " + poolName);
            }
        } catch (Throwable th) {
            throw new ConnectionPoolNotFoundException("The specified connection "
                    + "pool \""
                    + poolName
                    + "\" could not be found. The underlying "
                    + "error was a "
                    + th.getClass().getName()
                    + "The message was \""
                    + th.getMessage() + "\".");
        }

        return connectionPool;
    }
574632
static DBaseFileAttributePool getPool(URL dbaseFile) {
		DBaseFileAttributePool pool = null;
		if (dbaseFile != null) {
			if (pools == null) {
				pools = new WeakValueTreeMap<>();
			}
			pool = pools.get(dbaseFile.toExternalForm());
			if (pool == null) {
				pool = new DBaseFileAttributePool(dbaseFile);
				pools.put(dbaseFile.toExternalForm(), pool);
			}
		}
		return pool;
	}
596512
public synchronized T get ()
    {
        while (_count == 0) {
            try { wait(); } catch (InterruptedException e) {}
        }

        // pull the object off, and clear our reference to it
        T retval = _items[_start];
        _items[_start] = null;

        _start = (_start + 1) % _size;
        _count--;

        // if we are only filling 1/8th of the space, shrink by half
        if ((_size > MIN_SHRINK_SIZE) && (_size > _suggestedSize) &&
            (_count < (_size >> 3))) shrink();

        return retval;
    }
51279
@SuppressWarnings("unchecked")
    public final V get() {
        InternalThreadLocalMap threadLocalMap = InternalThreadLocalMap.get();
        Object v = threadLocalMap.indexedVariable(index);
        if (v != InternalThreadLocalMap.UNSET) {
            return (V) v;
        }

        return initialize(threadLocalMap);
    }
1224775
public T acquire() {
        T t = pool.poll();
        if (t == null) {
            t = create();
            ++count;
        }
        ++requests;
        // log();
        return t;
    }
680396
public ObjectContainer<T> take() throws InterruptedException
  {
    final ObjectContainer<T> ret = queue.take();
    currentMemory.addAndGet(-ret.getSize());
    return ret;
  }
374246
public ManagedObject get(Token token)
                    throws ObjectManagerException {
        final String methodName = "get";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass, methodName, new Object[] { token });

        if (gatherStatistics)
            numberOfGetRequests++;

        ManagedObject objectFromStore = null;
        synchronized (this) { // Avoid collisions with write operations.

            Directory.StoreArea storeArea = (Directory.StoreArea) directory.getEntry(new Long(token.storedObjectIdentifier));
            if (storeArea != null) { // Was the object written?
                if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
                    trace.debug(this,
                                cclass,
                                methodName,
                                new Object[] { storeArea });

                byte[] managedObjectBytes = new byte[(int) storeArea.length];

                try {
                    // Now read the serialized form of the ManagedObject.
                    storeFile.seek(storeArea.byteAddress);
                    storeFile.readFully(managedObjectBytes);

                } catch (java.io.IOException exception) {
                    // No FFDC Code Needed.
                    ObjectManager.ffdc.processException(this,
                                                        cclass,
                                                        methodName,
                                                        exception,
                                                        "1:455:1.35");

                    // check if the file handle is still good
                    try {
                        if (storeFile.getFD().valid())
                        {
                            TemporaryIOException tioe = new TemporaryIOException(this, exception);
                            if (trace.isEntryEnabled())
                                trace.exit(this,
                                           cclass,
                                           "get",
                                           tioe);
                            throw tioe;
                        }
                        else
                        {
                            // there is nothing more we can do really, so request a shutdown
                            // and throw a permanent ioexception.
                            objectManagerState.requestShutdown();

                            PermanentIOException pioe = new PermanentIOException(this, exception);
                            if (trace.isEntryEnabled())
                                trace.exit(this,
                                           cclass,
                                           "get",
                                           pioe);

                            throw pioe;
                        }
                    } catch (java.io.IOException e)
                    {
                        // there is nothing more we can do really, so request a shutdown
                        // and throw a permanent ioexception.
                        objectManagerState.requestShutdown();

                        PermanentIOException pioe = new PermanentIOException(this, exception);
                        if (trace.isEntryEnabled())
                            trace.exit(this,
                                       cclass,
                                       "get",
                                       pioe);

                        throw pioe;
                    }

                } // catch (java.io.IOException exception).

                // For debugging check guardBytes added before and after the serialized ManagedObject.
                if (useGuardBytes) {
                    byte[] unGuardedBytes = new byte[-guardBytesLength + managedObjectBytes.length - guardBytesLength];
                    for (int i = 0; i < guardBytesLength; i++) {
                        if (managedObjectBytes[i] != managedObjectBytes[guardBytesLength + unGuardedBytes.length + i]) {
                            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                                trace.exit(this,
                                           cclass,
                                           methodName);
                            throw new GuardBytesException(this,
                                                          token);
                        }
                    } // for guardBytes.

                    System.arraycopy(managedObjectBytes, // Source.
                                     guardBytesLength, // Source position.
                                     unGuardedBytes, // Destination.
                                     0, // Destination position.
                                     unGuardedBytes.length); // Length.

                    managedObjectBytes = unGuardedBytes;
                } // If (useGuardBytes).

                // Recover the ManagedObject from its serialized bytes.
                objectFromStore = ManagedObject.restoreFromSerializedBytes(managedObjectBytes,
                                                                           objectManagerState);
                // Cache the ManagedObject in memory, possibly push out a previously
                // cached ManagedObject.
                cache(objectFromStore);
            } // if (storeArea != null).
        } // synchronized(this).

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass, methodName, new Object[] { objectFromStore });
        return objectFromStore;
    }
367347
function () {
            var ret;
            if (this.count <= this.__maxObjects && this.freeCount > 0) {
                ret = this.__freeObjects.dequeue();
                this.__inUseObjects.push(ret);
            } else if (this.count < this.__maxObjects) {
                ret = this.createObject();
                this.__inUseObjects.push(ret);
            }
            return ret;
        }
873496
public function get()
	{
		// if at least an item is available in the pool
		if ( count($this->_poolItems) )
			$item = array_pop($this->_poolItems);
		
		// otherwise, we create a new instance
		else
			$item = call_user_func_array($this->_factorymethod, $this->_factorymethodparams);

		// now in use
		$this->_inUseItems[] = $item;
		
		// initialize item
		if ( $this->_initmethod )
			$item->{$this->_initmethod}();
			
		return $item;
	}
655830
@Nonnull
    StringBuilder get() {
        if( pool.size() == 0 ) {
            return new StringBuilder();
        } else {
            StringBuilder builder = pool.pollLast();
            builder.setLength( 0 );
            return builder;
        }
    }
1197100
public PoolSchedulable getPool(PoolInfo poolInfo) {
    PoolSchedulable pool = nameToMap.get(poolInfo);
    if (pool == null) {
      pool = new PoolSchedulable(poolInfo, getType(), configManager);
      PoolSchedulable prevPool = nameToMap.putIfAbsent(poolInfo, pool);
      if (prevPool != null) {
        pool = prevPool;
      }
    }
    return pool;
  }
1313797
protected T getObject() {
		final T object;
		if (reusedObject != null) {
			// REUSE THE SAME RECORD AFTER HAVING RESETTED IT
			object = reusedObject;
			object.reset();
		} else
			// CREATE A NEW ONE
			object = (T) database.newInstance(className);
		return object;
	}
1259580
public T get() {
    T value = object;
    if (value == null) {
      synchronized (this) {
        value = object;
        if (object == null) {
          object = value = supplier.get();
        }
      }
    }
    return value;
  }
315742
def pool(self):
        
        if self._pool is None:
            self._pool = ThreadPool(self.pool_threads)
        return self._pool
1081977
@SuppressWarnings("unchecked")
	public static <T> T get(Class<T> clazz, Object... params) {
		T obj = (T) pool.get(clazz);

		if (null == obj) {
			synchronized (Singleton.class) {
				obj = (T) pool.get(clazz);
				if (null == obj) {
					obj = ReflectUtil.newInstance(clazz, params);
					pool.put(clazz, obj);
				}
			}
		}

		return obj;
	}
43203
public static Pool retrievePool(UrlParser urlParser) {
    if (!poolMap.containsKey(urlParser)) {
      synchronized (poolMap) {
        if (!poolMap.containsKey(urlParser)) {
          if (poolExecutor == null) {
            poolExecutor = new ScheduledThreadPoolExecutor(1,
                new MariaDbThreadFactory("MariaDbPool-maxTimeoutIdle-checker"));
          }
          Pool pool = new Pool(urlParser, poolIndex.incrementAndGet(), poolExecutor);
          poolMap.put(urlParser, pool);
          return pool;
        }
      }
    }
    return poolMap.get(urlParser);
  }