// 
// Decompiled by Procyon v0.6.0
// 

package io.sentry;

import java.util.concurrent.ConcurrentHashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import io.sentry.util.AutoClosableReentrantLock;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ApiStatus;

@Deprecated
@ApiStatus.Internal
public final class SentrySpanStorage
{
    @Nullable
    private static volatile SentrySpanStorage INSTANCE;
    @NotNull
    private static final AutoClosableReentrantLock staticLock;
    @NotNull
    private final Map<String, ISpan> spans;
    
    @NotNull
    public static SentrySpanStorage getInstance() {
        if (SentrySpanStorage.INSTANCE == null) {
            try (final ISentryLifecycleToken ignored = SentrySpanStorage.staticLock.acquire()) {
                if (SentrySpanStorage.INSTANCE == null) {
                    SentrySpanStorage.INSTANCE = new SentrySpanStorage();
                }
            }
        }
        return SentrySpanStorage.INSTANCE;
    }
    
    private SentrySpanStorage() {
        this.spans = new ConcurrentHashMap<String, ISpan>();
    }
    
    public void store(@NotNull final String spanId, @NotNull final ISpan span) {
        this.spans.put(spanId, span);
    }
    
    @Nullable
    public ISpan get(@Nullable final String spanId) {
        return this.spans.get(spanId);
    }
    
    @Nullable
    public ISpan removeAndGet(@Nullable final String spanId) {
        return this.spans.remove(spanId);
    }
    
    static {
        staticLock = new AutoClosableReentrantLock();
    }
}
