From 332c33480ce4d9dacb9a85daae63ff8958ca983c Mon Sep 17 00:00:00 2001 From: Alfred Melch Date: Sat, 10 Aug 2019 20:49:57 +0200 Subject: [PATCH] run actions only in the right state --- benchmarking/src/benchmarks/BenchmarkSuite.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/benchmarking/src/benchmarks/BenchmarkSuite.js b/benchmarking/src/benchmarks/BenchmarkSuite.js index 0f27f96..0326a76 100644 --- a/benchmarking/src/benchmarks/BenchmarkSuite.js +++ b/benchmarking/src/benchmarks/BenchmarkSuite.js @@ -56,17 +56,25 @@ export class BenchmarkSuite { } start() { - this.state = 'running' - this.run() + if (this.state === 'initialized' || this.state === 'paused') { + this.state = 'running' + this.run() + } } pause() { - this.state = 'pause_requested' + if (this.state === 'running') this.state = 'pause_requested' } stop() { - this.state = 'stop_requested' - this.run() + if ( + this.state === 'running' || + this.state === 'paused' || + this.state === 'finished' + ) { + this.state = 'stop_requested' + this.run() + } } }