222 {
227 try
228 {
230 if (parent._doneWriting != null)
231 {
232 return false;
233 }
236 {
237 if (
count < parent._bufferedCapacity)
238 {
239 parent._items.EnqueueTail(
item);
240 return true;
241 }
242 if (parent._mode == BoundedChannelFullMode.Wait)
243 {
244 return false;
245 }
246 if (parent._mode == BoundedChannelFullMode.DropWrite)
247 {
248 Monitor.Exit(parent.SyncObj);
250 parent._itemDropped?.Invoke(
item);
251 return true;
252 }
253 T
obj = ((parent._mode == BoundedChannelFullMode.DropNewest) ? parent._items.DequeueTail() : parent._items.DequeueHead());
254 parent._items.EnqueueTail(
item);
255 Monitor.Exit(parent.SyncObj);
257 parent._itemDropped?.Invoke(
obj);
258 return true;
259 }
260 while (!parent._blockedReaders.IsEmpty)
261 {
264 {
266 break;
267 }
268 }
270 {
271 parent._items.EnqueueTail(
item);
272 listTail = parent._waitingReadersTail;
274 {
275 return true;
276 }
277 parent._waitingReadersTail = null;
278 }
279 }
280 finally
281 {
283 {
284 Monitor.Exit(parent.SyncObj);
285 }
286 }
288 {
290 }
291 else
292 {
294 }
295 return true;
296 }
readonly BoundedChannel< T > _parent