mirror of
https://github.com/copyrighttxt/watrbx-game-engine.git
synced 2026-09-04 20:57:49 +00:00
35 lines
899 B
C#
35 lines
899 B
C#
using System;
|
|
using Microsoft.Ccr.Core;
|
|
|
|
namespace Roblox
|
|
{
|
|
public class Interleaver
|
|
{
|
|
readonly Port<Action> exclusive = new Port<Action>();
|
|
readonly Port<Action> concurrent = new Port<Action>();
|
|
|
|
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(true, exclusive, action => action())
|
|
),
|
|
new ConcurrentReceiverGroup(
|
|
Arbiter.Receive(true, concurrent, action => action())
|
|
)
|
|
));
|
|
}
|
|
}
|
|
}
|