Browse Source

Lock around adding cached entries. (#243)

* Use a ConcurrentQueue

Fixed #179
davidfowl/dependencies
David Fowler 7 years ago
committed by GitHub
parent
commit
053ee69fea
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/Microsoft.Tye.Hosting/Model/Service.cs

4
src/Microsoft.Tye.Hosting/Model/Service.cs

@ -19,7 +19,7 @@ namespace Microsoft.Tye.Hosting.Model
{ {
if (CachedLogs.Count > 5000) if (CachedLogs.Count > 5000)
{ {
CachedLogs.Dequeue(); CachedLogs.TryDequeue(out _);
} }
CachedLogs.Enqueue(entry); CachedLogs.Enqueue(entry);
@ -64,7 +64,7 @@ namespace Microsoft.Tye.Hosting.Model
public Dictionary<object, object> Items { get; } = new Dictionary<object, object>(); public Dictionary<object, object> Items { get; } = new Dictionary<object, object>();
public Queue<string> CachedLogs { get; } = new Queue<string>(); public ConcurrentQueue<string> CachedLogs { get; } = new ConcurrentQueue<string>();
public Subject<string> Logs { get; } = new Subject<string>(); public Subject<string> Logs { get; } = new Subject<string>();

Loading…
Cancel
Save