Skip to content

Commit

Permalink
Rename NewStateMachine to just New
Browse files Browse the repository at this point in the history
Signed-off-by: Ondrej Kupka <ondra.cap@gmail.com>
  • Loading branch information
tchap committed Aug 17, 2013
1 parent 8c62fc7 commit 2842bec
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion statemachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type StateMachine struct {
// Create new StateMachine. Allocate internal memory for particular number of
// states and events, set internal channel size. As long as the internal channel
// is not full, most of the methods are non-blocking.
func NewStateMachine(initState State, initCtx Context, stateCount, eventCount, mailboxSize uint) *StateMachine {
func New(initState State, initCtx Context, stateCount, eventCount, mailboxSize uint) *StateMachine {
// Allocate enough space for the handlers.
table := make([][]EventHandler, stateCount)
for i := range table {
Expand Down
8 changes: 4 additions & 4 deletions statemachine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func cmdToString(t EventType) string {
// Tests ----------------------------------------------------------------------

func TestErrIllegalEvent(test *testing.T) {
sm := NewStateMachine(stateStopped, nil, 3, 3, 0)
sm := New(stateStopped, nil, 3, 3, 0)
defer sm.Terminate()

errCh := make(chan error, 1)
Expand All @@ -68,7 +68,7 @@ func TestErrIllegalEvent(test *testing.T) {
}

func TestErrTerminated(test *testing.T) {
sm := NewStateMachine(stateStopped, nil, 3, 3, 0)
sm := New(stateStopped, nil, 3, 3, 0)
err := sm.Terminate()
if err != nil {
test.Fatal(err)
Expand All @@ -81,7 +81,7 @@ func TestErrTerminated(test *testing.T) {
// Benchmarks -----------------------------------------------------------------

func BenchmarkStateMachine(bm *testing.B) {
sm := NewStateMachine(stateStopped, nil, 3, 3, 0)
sm := New(stateStopped, nil, 3, 3, 0)
sm.On(cmdStop, stateStopped, func(s State, ctx Context, e *Event) State {
return s
})
Expand All @@ -101,7 +101,7 @@ func ExampleStateMachine() {
var seqNum int = 1

// Allocate space for 3 states, 3 commands and 10 requests in the channel.
sm := NewStateMachine(stateStopped, &seqNum, 3, 3, 10)
sm := New(stateStopped, &seqNum, 3, 3, 10)

handleRun := func(s State, ctx Context, e *Event) (next State) {
var seq *int = ctx.(*int)
Expand Down

0 comments on commit 2842bec

Please sign in to comment.