import { ContextStackItem } from "./ContextStackItem";
/**
 * Reacts to Node.js asynchronous scheduling events and manages a scope stack that will
 * be preserved across those asynchronous invocations.
 */
export declare class ContextStack implements NodeJS.AsyncListenerCallbacks {
    private static ACTIVECONTEXT_PROCESS_SLOTNAME;
    private static scopeStack;
    /**
     * Initializes a new ContextStack.
     */
    constructor();
    /**
     * Gets the current context stack item.
     *
     * @returns The currently active context stack item.
     */
    /**
     * Sets the current context stack item.
     *
     * @param value The context stack item to make current.
     */
    private static activeContext;
    /**
     * Called by Node.js when an asynchronous function is being scheduled.
     *
     * The contextual items pushed onto the managed scope stack are captured and maintained
     * throughout the lifetime of the asynchronous function being scheduled.
     */
    create(): ContextStackItem;
    /**
     * Called by Node.js before an asynchronous function is to be executed.
     *
     * @param context Represents the current 'this' object.
     * @param contextStackItem The context stack item that was created for the asynchronous
     * function.
     */
    before(context: any, contextStackItem: ContextStackItem): void;
    /**
     * Called by Node.js after an asynchronous function has executed.
     *
     * @param context Represents the current 'this' object.
     * @param contextStackItem The context stack item that was created for the asynchronous
     * function.
     */
    after(context: any, contextStackItem: ContextStackItem): void;
    /**
     * Called by Node.js if an asynchronous function has thrown an error.
     *
     * @param contextStackItem The context stack item that was created for the asynchronous
     * function.
     * @param error The error that was thrown.
     */
    error(contextStackItem: any, error: Error): void;
    /**
     * Pushes contextual items onto the managed scope stack so that they can be captured as part
     * of a context stack item when the next asynchronous function is being scheduled.
     *
     * @param contextItems The array of objects to capture.
     */
    pushScope(contextItems: Object[]): void;
    /**
     * Searches the current context stack for a contextual item that was captured for the given
     * type of object.
     *
     * @param objectType The constructor function of the object that is required.
     * @returns The object that is currently in scope, or 'undefined' if none was found.
     */
    findContextObjectFromScope(objectType: Function): Object;
    /**
    * Bind an EventEmitter to the currently active context stack.
    *
    * @param emitter The EventEmitter to bind.
    */
    bindEventEmitter(emitter: NodeJS.EventEmitter): void;
    /**
     * Resets the managed scope stack.
     *
     * @returns A boolean flag indicating if the ContextStack could be reset.
     */
    static tryReset(): boolean;
    /**
     * Captures a given context stack item by incrementing the reference counts across
     * the entire stack.
     *
     * @param contextStackItem The context stack item that is to be captured.
     * @returns The original context stack item.
     */
    private static captureStackItem(contextStackItem);
    /**
     * Releases a given context stack item.
     *
     * @param contextStackItem The context stack item that is to be released.
     * @returns The parent context stack item.
     */
    private static releaseStackItem(contextStackItem);
    /**
     * Disposes of objects in a given object by calling their 'dispose()' function if they
     * have one.
     *
     * @param data An object that will be enumerated.
     */
    private static disposeStackItemObjects(data);
}
