public void FiberThroughputSingleDelegate(BenchmarkContext context) { for (var i = 0; i < FiberOperations;) { _fiber.Add(Operation); ++i; } SpinWait.SpinUntil(() => eventCount.Current >= FiberOperations, TimeSpan.FromSeconds(3)); }
public void Add(Action op) { if (_gracefulShutdownDeadline.HasTimeLeft) { _sharedFiber.Add(op); } }
public TimerAction(IFiber fiber, Action action, TimeSpan dueTime, TimeSpan interval) { _action = action; _interval = interval; _timer = new Timer(x => ExecuteOnTimerThread(fiber), null, dueTime, interval); fiber.Add(this); }
public TimerAction(IFiber fiber, Action action, TimeSpan dueTime) { _action = action; _interval = TimeSpan.FromMilliseconds(-1); _timer = new Timer(x => ExecuteOnTimerThread(fiber), null, dueTime, _interval); fiber.Add(this); }
public SnapshotRequest(IFiber fiber, ISubscriberPort <T> updatesPort, Action <T> receive, Action <TSnapshot> receiveSnapshot) { _fiber = fiber; _updatesPort = updatesPort; _receive = receive; _receiveSnapshot = receiveSnapshot; _fiber.Add(this); }
public void InvokeEvent(TTopic id, object sender, EventArgs e) { if (Subscribers.ContainsKey(id)) { var subscribers = Subscribers[id].Values.ToArray(); foreach (var subscriber in subscribers) { var h = subscriber; if (h == null) { continue; //shouldn't happen, but in case any delegates have been GC-ed... } Executor.Add(() => h.Invoke(sender, e)); } } }