diff options
author | Sung Yoon Whang <suwhang@microsoft.com> | 2019-08-07 09:14:38 -0700 |
---|---|---|
committer | William Godbe <wigodbe@microsoft.com> | 2019-08-07 09:14:38 -0700 |
commit | fe139940e7211be4f631a3a35ede45e350a1d7b9 (patch) | |
tree | d7e4e216f20a313ffd75860768b9375dec46a39f /tests/src | |
parent | 7259ed2b3676930cbe6c274fd71af9701ca69fe3 (diff) | |
download | coreclr-fe139940e7211be4f631a3a35ede45e350a1d7b9.tar.gz coreclr-fe139940e7211be4f631a3a35ede45e350a1d7b9.tar.bz2 coreclr-fe139940e7211be4f631a3a35ede45e350a1d7b9.zip |
Make counters use dedicated thread instead of timer (#25864) (#25978)
* Make a dedicated polling thread for EventCounters
* Cleanup
* remove debug prints
* nit
* Fix comment
* addressing issues from code review
* Fix an assertion from getting fired when we have multiple listeners
* Fix a test issue
* code review feedback
* Fix a potential deadlock
* Fix another deadlock
* Allow s_sleepDurationInMilliseconds to be reset to a larger value
* More issues fix
* Let thread wake up from sleep if needed
* Some suggestions for the counters fix.
The resulting behavior should be the same as what is there now (assuming I didn't mess anything up), these are all just code simplifications that hopefully make it easier to review and maintain going forward. In total I think this reduces the change size in CounterGroup.cs by ~30%.
- With the addition of the AutoResetEvent the ManualResetEvent is no longer needed, removed it.
- Removed the various if foo != null checks for the shared state, it is all initialized once when then thread is created and then assumed to be non-null elsewhere.
- Removed a 2nd lock acquisition inside OnTimer
- Replaced an if with Math.Min in PollForValues
* fix test
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/tracing/eventcounter/eventcounter.cs | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/tests/src/tracing/eventcounter/eventcounter.cs b/tests/src/tracing/eventcounter/eventcounter.cs index fffd1c8305..de1a0f0e41 100644 --- a/tests/src/tracing/eventcounter/eventcounter.cs +++ b/tests/src/tracing/eventcounter/eventcounter.cs @@ -76,6 +76,7 @@ namespace BasicEventSourceTests if (payload.Key.Equals("Mean")) { int mean = Int32.Parse(payload.Value.ToString()); + Console.WriteLine("Adding " + mean + " to known list of means"); means.Add(mean); } else if (payload.Key.Equals("DisplayName")) @@ -95,17 +96,12 @@ namespace BasicEventSourceTests public bool validateMean() { // we expect to see 1 because we wrote only 1s + // we *might* also see 0 because there is a period of time we didn't write stuff and got callback if (!means.Contains(1)) { + Console.WriteLine("Mean doesn't have a 1"); return false; } - - // we also expect to see 0 because there is a period of time we didn't write stuff and got callback - if (!means.Contains(0)) - { - return false; - } - return true; } } @@ -159,4 +155,4 @@ namespace BasicEventSourceTests } } } -}
\ No newline at end of file +} |