logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class ReentrancyGate

    Lets a piece of work refuse to run again WHILE it is still running, then allows it once more after it finishes. The canonical use is a handler that can be re-entered by something it itself triggers: a submit whose signals switch input maps and re-fire the still-held button, a save that reacts to its own change notification.

    The sibling of OnceGuard, and deliberately not the same thing: OnceGuard latches forever (the work happens once for the lifetime of the guard), while this one releases on Exit() (the work happens as often as it is asked, just never nested inside itself).

    Not thread-safe on purpose: re-entrancy here means "on the same call stack", which is what the callers guard against; a lock would hang the very re-entrant call it is meant to reject.

    Inheritance
    object
    ReentrancyGate
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    Namespace: Serenity.Shared.Utils
    Assembly: Serenity.Shared.dll
    Syntax
    public sealed class ReentrancyGate

    Constructors

    ReentrancyGate()

    Declaration
    public ReentrancyGate()

    Properties

    IsInside

    Whether a caller is currently inside the guarded section.

    Declaration
    public bool IsInside { get; }
    Property Value
    Type Description
    bool

    Methods

    Exit()

    Releases the gate, so the guarded work can be asked for again. Call it in a finally: a gate left taken makes the guarded work unreachable forever.

    Declaration
    public void Exit()

    TryEnter()

    Takes the gate when it is free, and reports whether it did.

    Declaration
    public bool TryEnter()
    Returns
    Type Description
    bool

    True when the caller may run the guarded work; false when it is already running.

    In this article
    © 2026 Serenity. All Rights Reserved