recommend a EventHandler.Do()

Test: manually verified equivalence
Bug: N/A
Change-Id: I2a5abd5b1230ab1f1b5851672e80833c5d18d5c7
This commit is contained in:
Usta Shrestha 2022-05-04 00:45:37 -04:00
parent 57d5937e6f
commit 2a95e590b6
2 changed files with 8 additions and 1 deletions

View file

@ -3648,7 +3648,7 @@ func (c *Context) SingletonName(singleton Singleton) string {
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
// completes then ErrBuildActionsNotReady is returned.
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())
}
// 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
// themselves been marked completed.
func (h *EventHandler) End(name string) {