public void TestConcreteConverter() { var converter = new OptionJsonConverter <Boxed <int> >(); Assert.False(converter.CanConvert(Option.None.GetType())); TestOptionsConverter(converter, Option.Some(Boxed.Of(42))); }
public void TestGenericNullRefConverter() { var converter = new GenericOptionJsonConverter(typeof(Maybe <>)); Assert.True(converter.CanConvert(Maybes.None.GetType())); TestOptionsConverter(converter, Maybes.Some(Boxed.Of(42))); }
public void TestGenericOptionConverter() { var converter = new GenericOptionJsonConverter(typeof(Option <>)); Assert.True(converter.CanConvert(Option.None.GetType())); TestOptionsConverter(converter, Option.Some(Boxed.Of(42))); }
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); } } }
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); } } }