using System; using Microsoft.Ccr.Core; namespace Roblox; public class Interleaver { private readonly Port exclusive = new Port(); private readonly Port concurrent = new Port(); public void DoExclusive(Action action) { exclusive.Post(action); } public void DoConcurrent(Action action) { concurrent.Post(action); } public Interleaver() { CcrService.Singleton.Activate(Arbiter.Interleave(new TeardownReceiverGroup(), new ExclusiveReceiverGroup(Arbiter.Receive(persist: true, exclusive, delegate(Action action) { action(); })), new ConcurrentReceiverGroup(Arbiter.Receive(persist: true, concurrent, delegate(Action action) { action(); })))); } }