recommend a EventHandler.Do() am: 2a95e590b6

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2095267

Change-Id: Id932c62693ec48b264d855a0cdf7559718f00b81
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Usta Shrestha 2022-05-31 16:11:02 +00:00 committed by Automerger Merge Worker
commit 0ca2d0cb67
2 changed files with 8 additions and 1 deletions

View file

@ -3648,7 +3648,7 @@ func (c *Context) SingletonName(singleton Singleton) string {
return "" return ""
} }
// WriteBuildFile writes the Ninja manifeset text for the generated build // WriteBuildFile writes the Ninja manifest text for the generated build
// actions to w. If this is called before PrepareBuildActions successfully // actions to w. If this is called before PrepareBuildActions successfully
// completes then ErrBuildActionsNotReady is returned. // completes then ErrBuildActionsNotReady is returned.
func (c *Context) WriteBuildFile(w io.StringWriter) error { func (c *Context) WriteBuildFile(w io.StringWriter) error {

View file

@ -62,6 +62,13 @@ func (h *EventHandler) Begin(name string) {
h.scopeStartTimes = append(h.scopeStartTimes, _now()) h.scopeStartTimes = append(h.scopeStartTimes, _now())
} }
// Do wraps a function with calls to Begin() and End().
func (h *EventHandler) Do(name string, f func()) {
h.Begin(name)
defer h.End(name)
f()
}
// End logs the end of an event. All events nested within this event must have // End logs the end of an event. All events nested within this event must have
// themselves been marked completed. // themselves been marked completed.
func (h *EventHandler) End(name string) { func (h *EventHandler) End(name string) {