Search in sources :

Example 6 with AsyncSemaphore

use of org.redisson.pubsub.AsyncSemaphore in project redisson by redisson.

the class RedissonPatternTopicReactive method removeListener.

@Override
public void removeListener(int listenerId) {
    AsyncSemaphore semaphore = commandExecutor.getConnectionManager().getSemaphore(name);
    semaphore.acquireUninterruptibly();
    PubSubConnectionEntry entry = commandExecutor.getConnectionManager().getPubSubEntry(name);
    if (entry == null) {
        semaphore.release();
        return;
    }
    entry.removeListener(name, listenerId);
    if (!entry.hasListeners(name)) {
        commandExecutor.getConnectionManager().punsubscribe(name, semaphore);
    } else {
        semaphore.release();
    }
}
Also used : PubSubConnectionEntry(org.redisson.connection.PubSubConnectionEntry) AsyncSemaphore(org.redisson.pubsub.AsyncSemaphore)

Example 7 with AsyncSemaphore

use of org.redisson.pubsub.AsyncSemaphore in project redisson by redisson.

the class RedissonTopicReactive method removeListener.

@Override
public void removeListener(int listenerId) {
    AsyncSemaphore semaphore = commandExecutor.getConnectionManager().getSemaphore(name);
    semaphore.acquireUninterruptibly();
    PubSubConnectionEntry entry = commandExecutor.getConnectionManager().getPubSubEntry(name);
    if (entry == null) {
        semaphore.release();
        return;
    }
    entry.removeListener(name, listenerId);
    if (!entry.hasListeners(name)) {
        commandExecutor.getConnectionManager().unsubscribe(name, semaphore);
    } else {
        semaphore.release();
    }
}
Also used : PubSubConnectionEntry(org.redisson.connection.PubSubConnectionEntry) AsyncSemaphore(org.redisson.pubsub.AsyncSemaphore)

Example 8 with AsyncSemaphore

use of org.redisson.pubsub.AsyncSemaphore in project redisson by redisson.

the class RedissonTopic method removeListener.

@Override
public void removeListener(MessageListener<?> listener) {
    AsyncSemaphore semaphore = commandExecutor.getConnectionManager().getSemaphore(name);
    semaphore.acquireUninterruptibly();
    PubSubConnectionEntry entry = commandExecutor.getConnectionManager().getPubSubEntry(name);
    if (entry == null) {
        semaphore.release();
        return;
    }
    entry.removeListener(name, listener);
    if (!entry.hasListeners(name)) {
        commandExecutor.getConnectionManager().unsubscribe(name, semaphore);
    } else {
        semaphore.release();
    }
}
Also used : PubSubConnectionEntry(org.redisson.connection.PubSubConnectionEntry) AsyncSemaphore(org.redisson.pubsub.AsyncSemaphore)

Example 9 with AsyncSemaphore

use of org.redisson.pubsub.AsyncSemaphore in project redisson by redisson.

the class RedissonTopic method removeListener.

@Override
public void removeListener(int listenerId) {
    AsyncSemaphore semaphore = commandExecutor.getConnectionManager().getSemaphore(name);
    semaphore.acquireUninterruptibly();
    PubSubConnectionEntry entry = commandExecutor.getConnectionManager().getPubSubEntry(name);
    if (entry == null) {
        semaphore.release();
        return;
    }
    entry.removeListener(name, listenerId);
    if (!entry.hasListeners(name)) {
        commandExecutor.getConnectionManager().unsubscribe(name, semaphore);
    } else {
        semaphore.release();
    }
}
Also used : PubSubConnectionEntry(org.redisson.connection.PubSubConnectionEntry) AsyncSemaphore(org.redisson.pubsub.AsyncSemaphore)

Example 10 with AsyncSemaphore

use of org.redisson.pubsub.AsyncSemaphore in project redisson by redisson.

the class RedissonPatternTopic method removeListener.

@Override
public void removeListener(PatternMessageListener<M> listener) {
    AsyncSemaphore semaphore = commandExecutor.getConnectionManager().getSemaphore(name);
    semaphore.acquireUninterruptibly();
    PubSubConnectionEntry entry = commandExecutor.getConnectionManager().getPubSubEntry(name);
    if (entry == null) {
        semaphore.release();
        return;
    }
    entry.removeListener(name, listener);
    if (!entry.hasListeners(name)) {
        commandExecutor.getConnectionManager().punsubscribe(name, semaphore);
    } else {
        semaphore.release();
    }
}
Also used : PubSubConnectionEntry(org.redisson.connection.PubSubConnectionEntry) AsyncSemaphore(org.redisson.pubsub.AsyncSemaphore)

Aggregations

AsyncSemaphore (org.redisson.pubsub.AsyncSemaphore)10 PubSubConnectionEntry (org.redisson.connection.PubSubConnectionEntry)8 RFuture (org.redisson.api.RFuture)2 TransferListener (org.redisson.pubsub.TransferListener)2