Skip to content

Commit 91403ab

Browse files
author
Gavin Norman
committed
Make restart work without calling stop first
1 parent d04a70a commit 91403ab

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/turtle/env/model/TestNode.d

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,25 @@ import ocean.task.Task;
128128
Restarts the fake node, reopening the listening socket on the same port
129129
determined in the initial call to start().
130130
131-
Notes:
132-
1. Restarting the node *does not* clear any data in its storage
133-
engine. To do that, call clear().
134-
2. You must call stop() first, before calling restart().
131+
Note: Restarting the node *does not* clear any data in its storage
132+
engine. To do that, call clear().
135133
136134
***************************************************************************/
137-
// TODO: make this work without requiring stop first
135+
138136
public void restart ( )
139137
{
140-
verify(this.state == State.Stopped, "Node has not been stopped");
138+
with ( State ) switch ( this.state )
139+
{
140+
case Stopped:
141+
break;
142+
case Running:
143+
this.stop();
144+
break;
145+
case Init:
146+
default:
147+
verify(false, "Node has not been started yet");
148+
break;
149+
}
141150

142151
this.restartListeners();
143152
this.register(theScheduler.epoll);

0 commit comments

Comments
 (0)