All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.ydb.coordination.impl.LeaseImpl Maven / Gradle / Ivy

The newest version!
package tech.ydb.coordination.impl;

import java.util.concurrent.CompletableFuture;

import tech.ydb.coordination.CoordinationSession;
import tech.ydb.coordination.SemaphoreLease;

/**
 *
 * @author Aleksandr Gorshenin
 */
class LeaseImpl implements SemaphoreLease {
    private final SessionImpl session;
    private final String name;

    LeaseImpl(SessionImpl session, String name) {
        this.session = session;
        this.name = name;
    }

    @Override
    public CoordinationSession getSession() {
        return session;
    }

    @Override
    public String getSemaphoreName() {
        return name;
    }

    @Override
    public CompletableFuture release() {
        return session.releaseSemaphore(name).thenApply(r -> null);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy