public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, IEventValidator eventValidation) { Action releaseAction = () => semaphore.Release(source); source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation.CurrentValidationCheck)); source.RegisterOnFalse(new ConditionalEventListener(releaseAction, eventValidation.CurrentValidationCheck)); eventValidation.OnVoid.Register(new CallOnce(releaseAction)); }
public static void ReleaseOn(this ISemaphoreInterection semaphore, IValueStateObserver <bool> source, Func <bool> eventValidation) { source.Synchronize(new ConditionalEventListener <bool>((value) => { if (value) { semaphore.Release(source); } else { semaphore.Block(source); } }, eventValidation)); }
public static void ReleaseOn(this ISemaphoreInterection semaphore, IValueStateObserver <bool> source) { source.Synchronize((value) => { if (value) { semaphore.Release(source); } else { semaphore.Block(source); } }); }
public static void ReleaseOn(this ISemaphoreInterection semaphore, UnityEngine.GameObject go, IBoolStateObserver additionalCondition = null) { var goEvents = go.EventRelay(); bool isValid = true; var name = go.HierarchyNameOrNull(); IBoolStateObserver condition = new BoolStateOperations.Not(goEvents.IsActive); if (additionalCondition != null) { condition = new BoolStateOperations.And(condition, additionalCondition); } Func <bool> eventValidation = () => isValid; condition.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Release(condition), eventValidation)); condition.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Block(condition), eventValidation)); goEvents.OnDestroy.Register(() => { isValid = false; semaphore.Release(condition); }); }
public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source, Func <bool> eventValidation) { source.RegisterOnTrue(new ConditionalEventListener(() => semaphore.Block(source), eventValidation)); source.RegisterOnFalse(new ConditionalEventListener(() => semaphore.Release(source), eventValidation)); }
public static void BlockOn(this ISemaphoreInterection semaphore, IBoolStateObserver source) { source.RegisterOnTrue(() => semaphore.Block(source)); source.RegisterOnFalse(() => semaphore.Release(source)); }