File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed
BitFaster.Caching.UnitTests/Buffers Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -180,13 +180,19 @@ public async Task WhileBufferIsFilledItemsCanBeTaken()
180180
181181 var fill = Threaded . Run ( 4 , ( ) =>
182182 {
183+ var spin = new SpinWait ( ) ;
183184 int count = 0 ;
184185 while ( count < 256 )
185186 {
186- if ( buffer . TryAdd ( "hello" ) == BufferStatus . Success )
187- {
188- count ++ ;
187+ while ( true )
188+ {
189+ if ( buffer . TryAdd ( "hello" ) == BufferStatus . Success )
190+ {
191+ break ;
192+ }
193+ spin . SpinOnce ( ) ;
189194 }
195+ count ++ ;
190196 }
191197 } ) ;
192198
@@ -210,13 +216,19 @@ public async Task WhileBufferIsFilledBufferCanBeDrained()
210216
211217 var fill = Threaded . Run ( 4 , ( ) =>
212218 {
219+ var spin = new SpinWait ( ) ;
213220 int count = 0 ;
214221 while ( count < 256 )
215- {
216- if ( buffer . TryAdd ( "hello" ) == BufferStatus . Success )
217- {
218- count ++ ;
222+ {
223+ while ( true )
224+ {
225+ if ( buffer . TryAdd ( "hello" ) == BufferStatus . Success )
226+ {
227+ break ;
228+ }
229+ spin . SpinOnce ( ) ;
219230 }
231+ count ++ ;
220232 }
221233 } ) ;
222234
You can’t perform that action at this time.
0 commit comments