public static bool AddAndWait(this Fiber fiber, Action operation, TimeSpan timeout) { var @event = new ManualResetEvent(false); fiber.Add(() => { try { operation(); } finally { @event.Set(); } }); bool completed = @event.WaitOne(timeout); fiber.Add(() => { var disposable = @event as IDisposable; disposable.Dispose(); }); return(completed); }
public void Add(Guid peerId, Uri peerUri, Guid subscriptionId, Uri endpointUri, string messageName, string correlationId) { var subscription = new PersistentSubscription(_busUri, peerId, peerUri, subscriptionId, endpointUri, messageName, correlationId); _fiber.Add(() => Add(subscription)); }
public void Send <T>(T message) { _fiber.Add(() => { _contextFactory.Create(message, _root); _agenda.Run(); }); }
private void Schedule(ExecuteScheduledAction action) { _fiber.Add(() => { _actions.Add(action); ExecuteExpiredActions(); }); }
void Schedule(ScheduledOperationExecuter action) { _fiber.Add(() => { _operations.Add(action); ExecuteExpiredActions(); }); }
public void Add(PersistentSubscription subscription) { _fiber.Add(() => { _subscriptions.Add(subscription); _log.DebugFormat("SubscriptionStorage.Add: {0} [{1}]", subscription, _subscriptions.Count); }); }
public void Register(Guid key, ActorRef actor) { _fiber.Add(() => { ActorRef existingActor; if (_keyIndex.TryGetValue(key, out existingActor)) { if (ReferenceEquals(existingActor, actor)) { return; } Remove(key, existingActor); } if (_actors.ContainsKey(actor)) { if (existingActor != actor) { _events.Send(new ActorUnregisteredImpl(this, actor, _actors[actor])); } _actors[actor] = key; _keyIndex[key] = actor; _events.Send(new ActorRegisteredImpl(this, actor, key)); return; } Add(key, actor); }); }
public ActorRef GetActor(Action <Inbox> initializer) { ActorInbox <TActor> inbox = null; Fiber fiber = _fiberFactory(new TryCatchOperationExecutor(ex => { inbox.Send <Fault>(new { ex.Message, ex.StackTrace }); })); Scheduler scheduler = _schedulerFactory(); inbox = new ActorInbox <TActor>(fiber, scheduler); TActor instance = CreateActorInstance(fiber, scheduler, inbox); ApplyConventions(instance, fiber, scheduler, inbox); if (initializer != null) { fiber.Add(() => initializer(inbox)); } return(inbox); }
public void Send <T>(T message) { _fiber.Add(() => { try { var envelope = new WcfMessageEnvelope { MessageType = typeof(T).AssemblyQualifiedName, Body = Serializer.Serialize(message), }; WcfChannel <WcfMessageEnvelope> proxy = _channelFactory.CreateChannel(); proxy.Send(envelope); var channel = proxy as IClientChannel; if (channel != null) { channel.Close(); } var disposable = proxy as IDisposable; if (disposable != null) { disposable.Dispose(); } } catch { // i hate doing this, but we don't want to take down the entire appdomain } }); }
void ScheduleUpdate() { if (!_updatePending) { _updatePending = true; _fiber.Add(PublishWorkerAvailability); } }
public void Start() { if (_log.IsInfoEnabled) { _log.Info("Timeout Service Starting"); } _unsubscribeToken = _bus.SubscribeInstance(this); _unsubscribeToken += _bus.SubscribeSaga <TimeoutSaga>(_repository); _fiber.Add(CheckExistingTimeouts); if (_log.IsInfoEnabled) { _log.Info("Timeout Service Started"); } }
public void Send(ConnectionContext context) { _fiber.Add(() => { context.Response.WriteHtml(_message); context.Complete(); }); }
void ScheduleUpdate() { if (!_updatePending) { _updatePending = true; _fiber.Add(() => PublishWorkerAvailability(10.Seconds())); } }
public void Send(ConnectionContext context) { _fiber.Add(() => { context.Response.RenderSparkView(_repo, "status.html"); context.Complete(); }); }
void ScheduleWakeUp() { if (!_wakeUpPending) { _wakeUpPending = true; _fiber.Add(() => { try { _bus.Endpoint.Send(new WakeUpWorker()); } catch { } }); } }
public void Send(T message) { _fiber.Add(() => { string body = _serializer.Serialize(message); _output.Send(body); }); }
public void Send <T>(T message) { _fiber.Add(() => { GetInbox <T>(); _adapter.Send(message); }); }
public void Send(string message) { _fiber.Add(() => { var msg = _serializer.Deserialize <T>(message); _output.Send(msg); }); }
public void Send(ICollection <T> messages) { if (messages.Count == 0) { return; } _fiber.Add(() => SendMessageToOutputChannel(messages.Last())); }
public void Send(TInput message) { _fiber.Add(() => { TOutput outputMessage = Converter(message); Output.Send(outputMessage); }); }
/// <summary> /// Enqueues the message to be written, after which it will invoke the completed action /// to complete the request/response exchange /// </summary> /// <param name="message"></param> public void Send(T message) { _fiber.Add(() => { _writer.Write(message); _completed(this); }); }
public void Execute() { if (_cancelled) { return; } _fiber.Add(_operation); }
public void Write(ArraySegment <byte> chunk, Action <ArraySegment <byte> > unsentCallback) { _fiber.Add(() => { if (_output != null) { _output.Send(chunk); } }); }
public void Send(T message) { _fiber.Add(() => { if (Filter(message)) { Output.Send(message); } }); }
public void Send(T message) { _fiber.Add(() => { Consumer <T> consumer = _selectiveConsumer(message); if (consumer != null) { consumer(message); } }); }
public void Send(T message) { _fiber.Add(() => { Channel <T> channel = Provider.GetChannel(message); if (channel == null) { return; } channel.Send(message); }); }
public void Send(T message) { _fiber.Add(() => { Type messageType = Type.GetType(message.MessageType, true, true); if (messageType == null) { return; } this.FastInvoke(new[] { messageType }, "Deserialize", message.Body); }); }
public ActorInstance Create(Action <Inbox> initializer) { Fiber fiber = _fiberFactory(); Scheduler scheduler = _schedulerFactory(); var inbox = new ActorInbox <AnonymousActor>(fiber, scheduler); _factory(fiber, scheduler, inbox); fiber.Add(() => initializer(inbox)); return(inbox); }
public void Send <T>(T message) { _fiber.Add(() => { var envelope = new WcfMessageEnvelope { MessageType = typeof(T).AssemblyQualifiedName, Body = Serializer.Serialize(message), }; _proxy.Send(envelope); }); }
public void Send(T message) { _fiber.Add(() => { Type messageType = Type.GetType(message.MessageType, true, true); if (messageType == null) { _log.Warn(x => x.Write("Unknown message type {0}, unable to deserialize message", message.MessageType)); return; } this.FastInvoke(new[] { messageType }, "Deserialize", message.Body); }); }