Ejemplo n.º 1
0
        public void TestConcurrentWaitOne()
        {
            UnixSignal s1 = new UnixSignal(Signum.SIGINT);
            UnixSignal s2 = new UnixSignal(Signum.SIGINT);
            Thread     a  = CreateWaitSignalThread(s1, 10000);
            Thread     b  = CreateWaitSignalThread(s2, 5000);
            Thread     c  = new Thread(delegate() {
                Thread.Sleep(1000);
                Stdlib.raise(Signum.SIGINT);
            });

            a.Start();
            b.Start();
            c.Start();
            a.Join();
            b.Join();
            c.Join();
            Assert.That(s1.Count, Is.EqualTo(1), "Expected 1 signal raised");
            Assert.That(s2.Count, Is.EqualTo(1), "Expected 1 signal raised");
        }
Ejemplo n.º 2
0
        public void TestDispose2()
        {
            UnixSignal a = new UnixSignal(Signum.SIGINT);
            UnixSignal b = new UnixSignal(Signum.SIGINT);

            Stdlib.raise(Signum.SIGINT);
            SleepUntilSignaled(a);

            Assert.AreEqual(a.Count, 1);
            Assert.AreEqual(b.Count, 1);

            b.Close();
            a.Reset();

            Stdlib.raise(Signum.SIGINT);
            SleepUntilSignaled(a);
            Assert.AreEqual(a.Count, 1);

            a.Close();
        }
Ejemplo n.º 3
0
        public void TestRaiseRTMINSignal()
        {
            if (!TestHelper.CanUseRealTimeSignals())
            {
                return;
            }

            int rtsigOffset = Utilities.FindFirstFreeRTSignal();

            Assert.That(rtsigOffset, Is.GreaterThan(-1), "No available RT signals");

            RealTimeSignum rts = new RealTimeSignum(rtsigOffset);

            using (UnixSignal signal = new UnixSignal(rts))
            {
                MultiThreadTest(signal, 5000, delegate() {
                    Thread.Sleep(1000);
                    Stdlib.raise(rts);
                });
            }
        }
Ejemplo n.º 4
0
 public void TestRaiseRTMINPlusOneSignal()
 {
     /*this number is a guestimate, but it's ok*/
     for (int i = 1; i < 10; ++i)
     {
         RealTimeSignum rts = new RealTimeSignum(i);
         UnixSignal     signal;
         try {
             signal = new UnixSignal(rts);
         } catch (ArgumentException) {                 /*skip the ones that are unavailable*/
             continue;
         }
         using (signal)
         {
             MultiThreadTest(signal, 5000, delegate() {
                 Thread.Sleep(1000);
                 Stdlib.raise(rts);
             });
         }
         return;
     }
     Assert.IsTrue(false, "#1 No available RT signal");
 }