Esempio n. 1
0
        public void TestConcreteConverter()
        {
            var converter = new OptionJsonConverter <Boxed <int> >();

            Assert.False(converter.CanConvert(Option.None.GetType()));
            TestOptionsConverter(converter, Option.Some(Boxed.Of(42)));
        }
Esempio n. 2
0
        public void TestGenericNullRefConverter()
        {
            var converter = new GenericOptionJsonConverter(typeof(Maybe <>));

            Assert.True(converter.CanConvert(Maybes.None.GetType()));
            TestOptionsConverter(converter, Maybes.Some(Boxed.Of(42)));
        }
Esempio n. 3
0
        public void TestGenericOptionConverter()
        {
            var converter = new GenericOptionJsonConverter(typeof(Option <>));

            Assert.True(converter.CanConvert(Option.None.GetType()));
            TestOptionsConverter(converter, Option.Some(Boxed.Of(42)));
        }
Esempio n. 4
0
 public override bool TryEnqueue(T res)
 {
     while (true)
     {
         var q    = queue;
         var @new = Boxed.Of(q.Value.Enqueue(res));
         if (Interlocked.CompareExchange(ref queue, @new, q) == q)
         {
             return(true);
         }
     }
 }
Esempio n. 5
0
 public override bool TryDequeue(out T res)
 {
     while (true)
     {
         var q = queue;
         if (q.Value.IsEmpty)
         {
             res = default(T);
             return(false);
         }
         var @new = Boxed.Of(q.Value.Dequeue(out res));
         if (Interlocked.CompareExchange(ref queue, @new, q) == q)
         {
             return(true);
         }
     }
 }