import { MutableHashSet } from "@tsplus/stdlib/collections/mutable/MutableHashSet/definition";
import { Tuple } from "@tsplus/stdlib/data/Tuple/definition";
import { MutableQueue } from "@tsplus/stdlib/collections/mutable/MutableQueue/definition";
import { Deferred } from "@effect/core/io/Deferred/definition";
import { Collection } from "@tsplus/stdlib/collections/Collection/definition";
import { AtomicBoolean } from "@tsplus/stdlib/data/AtomicBoolean";
import { Effect } from "@effect/core/io/Effect/definition";
import { EmptyMutableQueue } from "@tsplus/stdlib/collections/mutable/MutableQueue";
import type { AtomicHub } from "@effect/core/io/Hub/operations/_internal/AtomicHub";
import type { Subscription } from "@effect/core/io/Hub/operations/_internal/Subscription";
/**
 * A `Strategy<A>` describes the protocol for how publishers and subscribers
 * will communicate with each other through the hub.
 *
 * @tsplus type ets/Hub/Strategy
 */
export interface Strategy<A> {
    /**
     * Describes how publishers should signal to subscribers that they are
     * waiting for space to become available in the hub.
     */
    readonly handleSurplus: (hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, as: Collection<A>, isShutdown: AtomicBoolean) => Effect<never, never, boolean>;
    /**
     * Describes any finalization logic associated with this strategy.
     */
    readonly shutdown: Effect<never, never, void>;
    /**
     * Describes how subscribers should signal to publishers waiting for space
     * to become available in the hub that space may be available.
     */
    readonly unsafeOnHubEmptySpace: (hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>) => void;
    /**
     * Describes how subscribers waiting for additional values from the hub
     * should take those values and signal to publishers that they are no
     * longer waiting for additional values.
     */
    readonly unsafeCompletePollers: (hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, subscription: Subscription<A>, pollers: MutableQueue<Deferred<never, A>>) => void;
    /**
     * Describes how publishers should signal to subscribers waiting for
     * additional values from the hub that new values are available.
     */
    readonly unsafeCompleteSubscribers: (hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>) => void;
}
/**
 * @tsplus type ets/Hub/StrategyOps
 */
export interface StrategyOps {
}
export declare const Strategy: StrategyOps;
declare abstract class BaseStrategy<A> implements Strategy<A> {
    abstract handleSurplus(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, as: Collection<A>, isShutdown: AtomicBoolean): Effect<never, never, boolean>;
    abstract shutdown: Effect<never, never, void>;
    abstract unsafeOnHubEmptySpace(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>): void;
    unsafeCompletePollers(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, subscription: Subscription<A>, pollers: MutableQueue<Deferred<never, A>>): void;
    unsafeCompleteSubscribers(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>): void;
}
/**
 * A strategy that applies back pressure to publishers when the hub is at
 * capacity. This guarantees that all subscribers will receive all messages
 * published to the hub while they are subscribed. However, it creates the
 * risk that a slow subscriber will slow down the rate at which messages
 * are published and received by other subscribers.
 */
export declare class BackPressure<A> extends BaseStrategy<A> {
    publishers: MutableQueue<readonly [A, Deferred<never, boolean>, boolean]>;
    handleSurplus(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, as: Collection<A>, isShutdown: AtomicBoolean): Effect<never, never, boolean>;
    get shutdown(): Effect<never, never, void>;
    unsafeOnHubEmptySpace(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>): void;
    private unsafeOffer;
    private unsafeRemove;
}
/**
 * A strategy that drops new messages when the hub is at capacity. This
 * guarantees that a slow subscriber will not slow down the rate at which
 * messages are published. However, it creates the risk that a slow
 * subscriber will slow down the rate at which messages are received by
 * other subscribers and that subscribers may not receive all messages
 * published to the hub while they are subscribed.
 */
export declare class Dropping<A> extends BaseStrategy<A> {
    handleSurplus(_hub: AtomicHub<A>, _subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, _as: Collection<A>, _isShutdown: AtomicBoolean): Effect<never, never, boolean>;
    shutdown: Effect<never, never, void>;
    unsafeOnHubEmptySpace(_hub: AtomicHub<A>, _subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>): void;
}
/**
 * A strategy that adds new messages and drops old messages when the hub is
 * at capacity. This guarantees that a slow subscriber will not slow down
 * the rate at which messages are published and received by other
 * subscribers. However, it creates the risk that a slow subscriber will
 * not receive some messages published to the hub while it is subscribed.
 */
export declare class Sliding<A> extends BaseStrategy<A> {
    private unsafeSlidingPublish;
    handleSurplus(hub: AtomicHub<A>, subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>, as: Collection<A>, _isShutdown: AtomicBoolean): Effect<never, never, boolean>;
    shutdown: Effect<never, never, void>;
    unsafeOnHubEmptySpace(_hub: AtomicHub<A>, _subscribers: MutableHashSet<Tuple<[Subscription<A>, MutableQueue<Deferred<never, A>>]>>): void;
}
/**
 * @tsplus static ets/Hub/StrategyOps BackPressure
 * @tsplus location "@effect/core/io/Hub/operations/strategy"
 */
export declare function backPressureStrategy<A>(): Strategy<A>;
/**
 * @tsplus static ets/Hub/StrategyOps Dropping
 * @tsplus location "@effect/core/io/Hub/operations/strategy"
 */
export declare function droppingStrategy<A>(): Strategy<A>;
/**
 * @tsplus static ets/Hub/StrategyOps Sliding
 * @tsplus location "@effect/core/io/Hub/operations/strategy"
 */
export declare function slidingStrategy<A>(): Strategy<A>;
export {};
//# sourceMappingURL=strategy.d.ts.map