Skip to content

Commit

Permalink
refac(machine): make WhenDisposed a method
Browse files Browse the repository at this point in the history
  • Loading branch information
pancsta committed Jul 10, 2024
1 parent cdab12a commit 319f1e3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/machine/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ type Machine struct {
Tracers []Tracer
// If true, the machine has been Disposed and is no-op. Read-only.
Disposed bool
// Channel closing when the machine finished disposal. Read-only.
WhenDisposed chan struct{}
// ParentID is the ID of the parent machine (if any).
ParentID string
// Tags are optional tags for telemetry integrations etc.
Expand Down Expand Up @@ -109,6 +107,8 @@ type Machine struct {
currentHandler string
disposeHandlers []func()
timeLast T
// Channel closing when the machine finished disposal. Read-only.
whenDisposed chan struct{}
}

// NewCommon creates a new Machine instance with all the common options set.
Expand Down Expand Up @@ -175,7 +175,7 @@ func New(ctx context.Context, statesStruct Struct, opts *Opts) *Machine {
handlerEnd: make(chan bool),
handlerPanic: make(chan any),
handlerTimer: time.NewTimer(24 * time.Hour),
WhenDisposed: make(chan struct{}),
whenDisposed: make(chan struct{}),
}

// parse opts
Expand Down Expand Up @@ -384,7 +384,7 @@ func (m *Machine) dispose(force bool) {
m.disposeHandlers = nil

// the end
close(m.WhenDisposed)
close(m.whenDisposed)
}

// disposeEmitter detaches the emitter from the machine and disposes it.
Expand Down

0 comments on commit 319f1e3

Please sign in to comment.