@@ -103,16 +103,16 @@ constructor.
103103
104104### Validation
105105
106- Upon construction or after enqueueing an item, a ` DependencyQueue<T> ` instance
107- is in an unvalidated state. Before any items can be dequeued, the queue must
108- be validated. Do that by calling ` Validate() ` .
106+ After enqueueing an item, a ` DependencyQueue<T> ` instance is in an unvalidated
107+ state. Before any items can be dequeued, the queue must be validated. Do that
108+ by calling ` Validate() ` .
109109
110110``` csharp
111111var errors = queue .Validate ();
112112```
113113
114114If the queue is valid, ` Validate() ` returns an empty list of error objects.
115- Otherwiws , the list describes the problems found.
115+ Otherwise , the list describes the problems found.
116116
117117The web of dependencies between entries — the 'dependency graph' — can be
118118invalid in two ways.
@@ -126,17 +126,15 @@ invalid in two ways.
126126
127127### Dequeueing Items
128128
129- There are several ways to dequeue items from a ` DependencyQueue<T> ` instance.
130- All of them require the queue to be valid.
131-
132- The simplest way is to call ` TryDequeue() ` or ` TryDequeueAsync() ` , which return
133- the next entry in the queue or null if the queue is empty.
129+ To dequeue entries from a validated queue, call one of the dequeue methods
130+ ` Dequeue() ` or ` DequeueAsync() ` . Both methods yield the next entry in the
131+ queue, or ` null ` if the queue is empty.
134132
135133``` csharp
136- var entry = queue .TryDequeue ();
134+ var entry = queue .Dequeue ();
137135```
138136``` csharp
139- await var entry = queue .TryDequeueAsync (cancellation : cancellationToken );
137+ var entry = await queue .DequeueAsync (cancellation : cancellationToken );
140138```
141139
142140The item is available in the ` Value ` property of the returned entry.
@@ -148,19 +146,19 @@ call `Complete()` to inform the queue.
148146queue .Complete (entry );
149147```
150148
151- ` TryDequeue ()` , ` TryDequeueAsync ()` , and ` Complete() ` are thread-safe. For
152- full thread safety information, see the [ Thread Safety] ( #thread-safety ) section
149+ ` Dequeue ()` , ` DequeueAsync ()` , and ` Complete() ` are thread-safe. For full
150+ thread safety information, see the [ Thread Safety] ( #thread-safety ) section
153151below.
154152
155- All dequeue methods support an optional predicate parameter. If the caller
153+ The dequeue methods support an optional predicate parameter. If the caller
156154provides a predicate, the queue tests each ready-to-dequeue item against the
157155predicate and yields the first entry for which the predicate returns ` true ` .
158156If the predicate does not return ` true ` for any ready-to-dequeue item, then
159157the dequeue method blocks until an item becomes available that does satisfy the
160158predicate.
161159
162160``` csharp
163- await var entry = queue .TryDequeueAsync (
161+ var entry = await queue .DequeueAsync (
164162 item => MyCustomPredicate (item ),
165163 cancellationToken
166164);
@@ -188,26 +186,19 @@ _ = view.Topics["Foo"].RequiredBy; // Entries that require topic "Foo"
188186
189187### States
190188
191- A ` DependencyQueue<T> ` instance has four possible states:
189+ A ` DependencyQueue<T> ` instance has three possible states:
192190
193191- ** Unvalidated:**
194192 - The queue has not been validated or was found to be invalid.
195193 - Items can be enqueued.
196194 - Dequeue methods will throw ` InvalidOperationException ` .
197- - Call ` Validate() ` to transition to the ** Valid** state.
198- - Call ` SetEnding() ` to transition to the ** Ending** state.
199- - Call ` Dispose() ` to transition to the ** Disposed** state.
195+ - Call ` Validate() ` or ` Clear() ` to transition to the ** Valid** state.
196+ - Call ` Dispose() ` to transition to the ** Disposed** state.
200197- ** Valid:**
201198 - The queue was found to be valid.
202199 - Items can be dequeued.
203200 - Enqueuing a new item transitions back to the ** Unvalidated** state.
204- - Call ` SetEnding() ` to transition to the ** Ending** state.
205- - Call ` Dispose() ` to transition to the ** Disposed** state.
206- - ** Ending:**
207- - Queue processing is ending early.
208- - Items can be enqueued, but will be ignored.
209- - Dequeue methods will return ` null ` immediately.
210- - Call ` Dispose() ` to transition to the ** Disposed** state.
201+ - Call ` Dispose() ` to transition to the ** Disposed** state.
211202- ** Disposed:**
212203 - The queue has been disposed and is no longer unsable.
213204 - Most methods will throw ` ObjectDisposedException ` .
@@ -224,15 +215,15 @@ Most methods of `DependencyQueue<T>` are thread-safe. Specifically:
224215
225216- The ` Validate() ` method is thread-safe.
226217
227- - The dequeue methods (` TryDequeue ()` , ` TryDequeueAsync ()` , and ` Complete() ` )
218+ - The dequeue methods (` Dequeue ()` , ` DequeueAsync ()` , and ` Complete() ` )
228219 are thread-safe.
229220
230221- The inspection methods (` Inspect() ` and ` InspectAsync() ` ) are thread-safe, as
231222 are the objects they return.
232223
233- - The ` SetEnding ()` method is thread-safe.
224+ - The ` Clear ()` method is thread-safe.
234225
235- - The ` Dispose() ` is <strong >Not </strong > thread-safe.
226+ - The ` Dispose() ` method is <strong >NOT </strong > thread-safe.
236227
237228## Examples
238229
@@ -286,7 +277,7 @@ if (errors.Any())
286277 throw new InvalidBurgerException (errors );
287278
288279// Now build the burger
289- while (queue .TryDequeue () is { } entry )
280+ while (queue .Dequeue () is { } entry )
290281{
291282 Console .WriteLine ($" Executing: {entry .Name }" );
292283
0 commit comments