Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes TimedPhase auto-closeable. #143

Merged
merged 4 commits into from
Mar 1, 2017
Merged

Commits on Mar 1, 2017

  1. Makes TimedPhase auto-closeable.

    --This would allow us to wrap timed phases in a try-with-resources
    block:
    
    ```java
       try(TimedPhase phase = RequestLog.startTiming("timerAllTheThings") {
                      doAllTheThings();
        }
    ```
    
    --This has several advantages over the current approach:
            1. We always want to wrap the code that stops a timer in a finally block.
                Otherwise, the timer won't be stopped if we have an
                exception. try-with-resources makes that clean.
            2. It reduces the chances of typos when starting and stopping
                timers. It also reduces the chances of people staring a timer
                and then forgetting to stop it.
            3. It is more concise.
    
    --This has several limitations:
            1. The minimum effort code to implement it is awkward. We'll
                need to do a much more significant (and not yet clear) refactor
                of RequestLog to handle this cleanly.
            2. Timers that cross threads can't be handled this way. Those
                still need to be stopped and started manually.
    
    --Consequences that are more mixed:
            1. It exposes a lot more of the inner workings of RequestLog.
                This could make it easier to customers to perform their own
                custom timings, but it also exposes code that is very easy
                to use incorrectly if you don't have a strong understanding
                of it.
    archolewa committed Mar 1, 2017
    Configuration menu
    Copy the full SHA
    d914937 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9195569 View commit details
    Browse the repository at this point in the history
  3. Timings now use the try-with-resources blocks.

    --Those timers that are started and stopped in the same context now use
    try-with-resources blocks that start the timer.
    archolewa committed Mar 1, 2017
    Configuration menu
    Copy the full SHA
    320bb5e View commit details
    Browse the repository at this point in the history
  4. Updates CHANGELOG.

    archolewa committed Mar 1, 2017
    Configuration menu
    Copy the full SHA
    cf67dc0 View commit details
    Browse the repository at this point in the history