Skip to content

Commit

Permalink
Add named interface for Stop(). Fixes pkg#60
Browse files Browse the repository at this point in the history
  • Loading branch information
kishaningithub authored Jul 15, 2021
1 parent 3704c8d commit 63d689a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,14 @@ func (p *Profile) Stop() {
// started is non zero if a profile is running.
var started uint32

type Stopper interface {
Stop()
}

// Start starts a new profiling session.
// The caller should call the Stop method on the value returned
// to cleanly stop profiling.
func Start(options ...func(*Profile)) interface {
Stop()
} {
func Start(options ...func(*Profile)) Stopper {
if !atomic.CompareAndSwapUint32(&started, 0, 1) {
log.Fatal("profile: Start() already called")
}
Expand Down

0 comments on commit 63d689a

Please sign in to comment.