package com.qmth.boot.core.concurrent.service;

import com.qmth.boot.core.concurrent.model.Semaphore;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;

/**
 * 内置并发服务接口
 */
public interface ConcurrentService {

    /**
     * 获取普通锁
     *
     * @param name
     * @return
     */
    Lock getLock(String name);

    /**
     * 普通锁是否已上锁
     *
     * @param name
     * @return
     */
    boolean isLocked(String name);

    /**
     * 获取读写锁
     *
     * @param name
     * @return
     */
    ReadWriteLock getReadWriteLock(String name);

    /**
     * 读锁是否已上锁
     *
     * @param name
     * @return
     */
    boolean isReadLocked(String name);

    /**
     * 写锁是否已上锁
     *
     * @param name
     * @return
     */
    boolean isWriteLocked(String name);

    /**
     * 获取抽象信号量
     *
     * @param name
     * @return
     */
    Semaphore getSemaphore(String name);

}
