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

org.zodiac.reactor.event.FastThreadLocalAsyncEventHooks Maven / Gradle / Ivy

The newest version!
package org.zodiac.reactor.event;

import java.util.LinkedList;

import io.netty.util.concurrent.FastThreadLocal;
import reactor.core.publisher.Mono;

public class FastThreadLocalAsyncEventHooks extends AsyncEventHooks {

    private final FastThreadLocal> hooks = new FastThreadLocal>() {
        @Override
        protected LinkedList initialValue() {
            return new LinkedList<>();
        }
    };

    private FastThreadLocalAsyncEventHooks() {
    }

    @Override
    protected LinkedList getHooksList() {
        return hooks.get();
    }

    @Override
    protected LinkedList getHooksListIfExists() {
        return hooks.getIfExists();
    }

    public static AutoUnbindable bind(AsyncEventHook hook) {
        return getInstance().bindHook(hook);
    }

    static Mono hookFirst(AsyncEvent event, Mono publisher) {
        return getInstance().hookToFirst(event, publisher);
    }

    static Mono hookAsync(AsyncEvent event, Mono publisher) {
        return getInstance().hookToAsync(event, publisher);
    }

    private static FastThreadLocalAsyncEventHooks getInstance() {
        return NettyAsyncEventHooksHolder.INSTANCE;
    }

    private static class NettyAsyncEventHooksHolder {
        private static final FastThreadLocalAsyncEventHooks INSTANCE = new FastThreadLocalAsyncEventHooks();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy