what-the-bank/sources/io/grpc/internal/SharedResourcePool.java

28 lines
835 B
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.grpc.internal;
import io.grpc.internal.SharedResourceHolder;
/* loaded from: classes6.dex */
public final class SharedResourcePool<T> implements ObjectPool<T> {
private final SharedResourceHolder.Resource<T> resource;
private SharedResourcePool(SharedResourceHolder.Resource<T> resource) {
this.resource = resource;
}
public static <T> SharedResourcePool<T> forResource(SharedResourceHolder.Resource<T> resource) {
return new SharedResourcePool<>(resource);
}
@Override // io.grpc.internal.ObjectPool
public final T getObject() {
return (T) SharedResourceHolder.get(this.resource);
}
@Override // io.grpc.internal.ObjectPool
public final T returnObject(Object obj) {
SharedResourceHolder.release(this.resource, obj);
return null;
}
}