private void ProcessWork(Loop loop, IAsyncWatcher watcher, EventTypes revents) { int remaining = maxWorkPerLoop + 1; while (--remaining > 0) { Action action; if (workQueue.TryDequeue(out action)) { try { action(); } catch (Exception ex) { Console.WriteLine("Error in processing synchronized action"); Console.WriteLine(ex); } } else { break; } } if (remaining == 0) { asyncWatcher.Send(); } }
internal virtual void HandleEnd(Loop loop, IAsyncWatcher watcher, EventTypes revents) { if (OnEnd != null) { OnEnd(); } }
public Boundary(Context context, int maxWorkPerLoop) { asyncWatcher = context.CreateAsyncWatcher(ProcessWork); asyncWatcher.Start(); workQueue = new ConcurrentQueue<Action>(); this.maxWorkPerLoop = maxWorkPerLoop; }
public Boundary(Context context, int maxWorkPerLoop) { asyncWatcher = context.CreateAsyncWatcher(ProcessWork); asyncWatcher.Start(); workQueue = new ConcurrentQueue <Action> (); this.maxWorkPerLoop = maxWorkPerLoop; }
public Boundary(IOLoop loop, int maxWorkPerLoop) { asyncWatcher = loop.NewAsyncWatcher(ProcessWork); asyncWatcher.Start(); workQueue = new ConcurrentQueue <Action> (); this.maxWorkPerLoop = maxWorkPerLoop; }
public void Complete(Action callback) { completeWatcher = IOLoop.Instance.NewAsyncWatcher(delegate { completeWatcher.Dispose(); completeWatcher = null; callback(); }); completeWatcher.Start(); Stream.End(completeWatcher.Send); }
public void Complete(Action callback) { IAsyncWatcher completeWatcher = null; completeWatcher = Context.CreateAsyncWatcher(delegate { completeWatcher.Dispose(); callback(); }); completeWatcher.Start(); Stream.End(completeWatcher.Send); }
public AsyncWatcher(Context context, Action <T> callback) { asyncWatcher = context.CreateAsyncWatcher(() => { T item; lock (queue) { item = queue.Dequeue(); } if (callback != null) { callback(item); } }); }
public void Dispose() { Socket = null; if (Stream != null) { Stream.Dispose(); Stream = null; } if (end_watcher != null) { end_watcher.Dispose(); end_watcher = null; } }
public HttpEntity() { end_watcher = IOLoop.Instance.NewAsyncWatcher(HandleEnd); end_watcher.Start(); }
public HttpEntity(Context context) { this.Context = context; end_watcher = context.CreateAsyncWatcher(HandleEnd); end_watcher.Start(); }