Skip to content

Commit

Permalink
[Refactor] Recylers to Common Library
Browse files Browse the repository at this point in the history
This commit refactors the common recylers logic from the server module
to the core library to make the base functionality available to concrete
implementations across the codebase. This is done to support cloud
native or serverless implementations. Until JPM is enabled, the classes
remain marked for internal use only. Determining which classes will be
exported will dictate if/when these doc labels are switched to API.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
  • Loading branch information
nknize committed Aug 1, 2023
1 parent f2ca769 commit bca8611
Show file tree
Hide file tree
Showing 17 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public static <T> Recycler.Factory<T> dequeFactory(final Recycler.C<T> c, final
/**
* Wrap the provided recycler so that calls to {@link Recycler#obtain()} and {@link Recycler.V#close()} are protected by
* a lock.
*
* @opensearch.internal
*/
public static <T> Recycler<T> locked(final Recycler<T> recycler) {
return new FilterRecycler<T>() {
Expand Down Expand Up @@ -140,7 +142,7 @@ public static <T> Recycler<T> concurrent(final Recycler.Factory<T> factory, fina
private final Recycler<T>[] recyclers;

{
@SuppressWarnings("unchecked")
@SuppressWarnings({ "rawtypes", "unchecked" })
final Recycler<T>[] recyclers = new Recycler[concurrencyLevel];
this.recyclers = recyclers;
for (int i = 0; i < concurrencyLevel; ++i) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/** Common Recycler functionality for recycling objects */
package org.opensearch.common.recycler;

0 comments on commit bca8611

Please sign in to comment.