code: func (s *Simulation) Run(ctx context.Context, f RunFunc) (r Result) {
  	//if the option is set to run a HTTP server with the simulation,
  	//init the server and start it
  	start := time.Now()
  	if s.httpSrv != nil {
  		log.Info("Waiting for frontend to be ready...(send POST /runsim to HTTP server)")
  		//wait for the frontend to connect
  		select {
  		case <-s.runC:
  		case <-ctx.Done():
  			return Result{
  				Duration: time.Since(start),
  				Error:    ctx.Err(),
  			}
  		}
  		log.Info("Received signal from frontend - starting simulation run.")
  	}
  	errc := make(chan error)
  	quit := make(chan struct{})
  	defer close(quit)
  	go func() {
  		select {
  		case errc <- f(ctx, s):
  		case <-quit:
  		}
  	}()
  	var err error
  	select {
  	case <-ctx.Done():
  		err = ctx.Err()
  	case err = <-errc:
  	}
  	return Result{
  		Duration: time.Since(start),
  		Error:    err,
  	}
  }
docs: // Run calls the RunFunc function while taking care of
  // cancellation provided through the Context.