Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Channel.cs
Go to the documentation of this file.
2
3public static class Channel
4{
6 {
7 return new UnboundedChannel<T>(runContinuationsAsynchronously: true);
8 }
9
11 {
12 if (options != null)
13 {
14 if (!options.SingleReader)
15 {
16 return new UnboundedChannel<T>(!options.AllowSynchronousContinuations);
17 }
18 return new SingleConsumerUnboundedChannel<T>(!options.AllowSynchronousContinuations);
19 }
20 throw new ArgumentNullException("options");
21 }
22
24 {
25 if (capacity < 1)
26 {
27 throw new ArgumentOutOfRangeException("capacity");
28 }
29 return new BoundedChannel<T>(capacity, BoundedChannelFullMode.Wait, runContinuationsAsynchronously: true, null);
30 }
31
36
37 public static Channel<T> CreateBounded<T>(BoundedChannelOptions options, Action<T>? itemDropped)
38 {
39 if (options == null)
40 {
41 throw new ArgumentNullException("options");
42 }
43 return new BoundedChannel<T>(options.Capacity, options.FullMode, !options.AllowSynchronousContinuations, itemDropped);
44 }
45}
46public abstract class Channel<T> : Channel<T, T>
47{
48}
49public abstract class Channel<TWrite, TRead>
50{
51 public ChannelReader<TRead> Reader { get; protected set; }
52
53 public ChannelWriter<TWrite> Writer { get; protected set; }
54
55 public static implicit operator ChannelReader<TRead>(Channel<TWrite, TRead> channel)
56 {
57 return channel.Reader;
58 }
59
60 public static implicit operator ChannelWriter<TWrite>(Channel<TWrite, TRead> channel)
61 {
62 return channel.Writer;
63 }
64}
static Channel< T > CreateUnbounded< T >()
Definition Channel.cs:5
static Channel< T > CreateBounded< T >(int capacity)
Definition Channel.cs:23