public void Read(int fd, byte[] buffer, long offset, long length, Action <int, byte[], int> callback) { Libeio.read(fd, buffer, offset, length, (arg1, arg2, arg3) => { outstanding.Enqueue(() => callback(arg1, arg2, arg3)); pulse.Send(); }); }
public void ExecuteOnTargetLoop(Action action) { int count; lock ( workQueue ) { workQueue.Enqueue(action); count = workQueue.Count; } if (count < 2) { asyncWatcher.Send(); } }
public SignalWatcher(Loop loop, Signum[] signals, Action <Signum> callback) { Signals = signals; unixSignals = new UnixSignal[signals.Length]; for (int i = 0; i < signals.Length; i++) { unixSignals[i] = new UnixSignal((Mono.Unix.Native.Signum)signals[i]); } watcher = new AsyncWatcher <Signum>(loop); watcher.Callback += (key) => { if (callback != null) { callback(key); } }; thread = new Thread((o) => { while (true) { var index = UnixSignal.WaitAny(unixSignals); watcher.Send(Signals[index]); } }); }
public void ArgumentNullExceptions() { Assert.Throws <ArgumentNullException>(() => new Async(null as Loop)); Assert.Throws <ArgumentNullException>(() => new AsyncWatcher <int>(null as Loop)); using (var asyncWatcher = new AsyncWatcher <int>()) { Assert.Throws <ArgumentNullException>(() => asyncWatcher.Send(null as IEnumerable <int>)); } }
public void ArgumentNullExceptions() { Assert.Throws<ArgumentNullException>(() => new Async(null as Loop)); Assert.Throws<ArgumentNullException>(() => new AsyncWatcher<int>(null as Loop)); using (var asyncWatcher = new AsyncWatcher<int>()) { Assert.Throws<ArgumentNullException>(() => asyncWatcher.Send(null as IEnumerable<int>)); } }
public static void ArgumentNullExceptions() { Assert.Throws <ArgumentNullException>(() => new Async(null as Loop)); Assert.Throws <ArgumentNullException>(() => new AsyncWatcher <int>(null as Loop)); var async = new Async(); var asyncWatcher = new AsyncWatcher <int>(); Assert.Throws <ArgumentNullException>(() => asyncWatcher.Send(null as IEnumerable <int>)); async.Close(); asyncWatcher.Close(); }
public static void ArgumentNullExceptions() { Assert.Throws<ArgumentNullException>(() => new Async(null as Loop)); Assert.Throws<ArgumentNullException>(() => new AsyncWatcher<int>(null as Loop)); var async = new Async(); var asyncWatcher = new AsyncWatcher<int>(); Assert.Throws<ArgumentNullException>(() => asyncWatcher.Send(null as IEnumerable<int>)); async.Close(); asyncWatcher.Close (); }
public static void Main(string[] args) { string configfile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/.config/quassel-irc.org/quasselclient.conf"; var settings = new Settings(configfile); QuasselTypes.Init(); var acc = settings.Accounts[settings.AutoConnectAccount]; var coreConnection = new CoreConnection(acc.HostName, acc.Port, acc.User, acc.Password, false); Application.Init(); var qc = new QuasselClient(coreConnection); ThemeManager = new ThemeManger(); MainWindow = ThemeManager.Default.CreateMainWindow(qc); AsyncWatcher<QVariant> listnotifier = new AsyncWatcher<QVariant>((packet) => qc.Handle(packet)); AsyncWatcher<Exception> excenotifier = new AsyncWatcher<Exception>((exce) => qc.Handle(exce)); var nt = new Thread((obj) => { coreConnection.ReceivePacket += (packet) => { listnotifier.Send(packet); }; coreConnection.Exception += (exception) => { excenotifier.Send(exception); }; coreConnection.Connect(); coreConnection.Loop(); }); nt.Start(); Application.End += (() => { nt.Abort(); }); Application.Run(MainWindow); }
public static void Synchronize <T> (Action <IManosContext, T> action, IManosContext context, T arg) { if (action == null) { throw new ArgumentNullException("action"); } if (context == null) { throw new ArgumentNullException("context"); } if (context.Transaction.ResponseReady && context.Transaction.Response == null) { throw new InvalidOperationException("Response stream has been closed"); } waitingSyncBlocks.Enqueue(new SynchronizedBlock <T> (action, context, arg)); syncBlockWatcher.Send(); }
public SignalWatcher(Context context, Signum[] signals, Action<Signum> callback) { Signals = signals; unixSignals = new UnixSignal[signals.Length]; for (int i = 0; i < signals.Length; i++) { unixSignals[i] = new UnixSignal(signals[i]); } watcher = new AsyncWatcher<Signum>(context, (key) => { if (callback != null) { callback(key); } }); thread = new Thread((o) => { while (true) { var index = UnixSignal.WaitAny(unixSignals); watcher.Send(Signals[index]); } }); }
public SignalWatcher(Loop loop, Signum[] signals, Action<Signum> callback) { Signals = signals; unixSignals = new UnixSignal[signals.Length]; for (int i = 0; i < signals.Length; i++) { unixSignals[i] = new UnixSignal((Mono.Unix.Native.Signum)signals[i]); } watcher = new AsyncWatcher<Signum>(loop); watcher.Callback += (key) => { if (callback != null) { callback(key); } }; thread = new Thread((o) => { while (true) { var index = UnixSignal.WaitAny(unixSignals); watcher.Send(Signals[index]); } }); }
public AsyncCoreConnection(Loop loop, CoreConnection coreConnection) { Loop = loop; CoreConnection = coreConnection; listnotifier = new AsyncWatcher<QVariant>((packet) => OnReceivePacket(packet)); exceptionnotifier = new AsyncWatcher<Exception>((exception) => OnException(exception)); thread = new Thread((obj) => { coreConnection.ReceivePacket += (packet) => { listnotifier.Send(packet); }; coreConnection.Exception += (exception) => { //exceptionnotifier.Send(exception); }; coreConnection.Connect(); coreConnection.Loop(); }); }
public void ExecuteOnTargetLoop(Action action) { workQueue.Enqueue(action); asyncWatcher.Send(); }
public void End() { end_watcher.Send(); }
private void EIOWantPoll() { Console.WriteLine("want poll"); want_poll_watcher.Send(); }
private void EIODonePoll() { Console.WriteLine("done poll"); done_poll_watcher.Send(); }