Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ TryWrite()

override bool System.Threading.Channels.UnboundedChannel< T >.UnboundedChannelWriter.TryWrite ( T item)
inline

Definition at line 178 of file UnboundedChannel.cs.

179 {
182 while (true)
183 {
185 listTail = null;
186 lock (parent.SyncObj)
187 {
188 if (parent._doneWriting != null)
189 {
190 return false;
191 }
192 if (parent._blockedReaders.IsEmpty)
193 {
194 parent._items.Enqueue(item);
195 listTail = parent._waitingReadersTail;
196 if (listTail == null)
197 {
198 return true;
199 }
200 parent._waitingReadersTail = null;
201 }
202 else
203 {
204 asyncOperation = parent._blockedReaders.DequeueHead();
205 }
206 }
207 if (asyncOperation == null)
208 {
209 break;
210 }
211 if (asyncOperation.TrySetResult(item))
212 {
213 return true;
214 }
215 }
216 ChannelUtilities.WakeUpWaiters(ref listTail, result: true);
217 return true;
218 }

References System.Threading.Channels.UnboundedChannel< T >.UnboundedChannelWriter._parent, System.item, and System.Threading.Channels.ChannelUtilities.WakeUpWaiters().

Referenced by System.Threading.Channels.UnboundedChannel< T >.UnboundedChannelWriter.WriteAsync().