virtual RosbagRecorderRunResult Run()

in rosbag_cloud_recorders/include/rosbag_cloud_recorders/utils/rosbag_recorder.h [63:97]


  virtual RosbagRecorderRunResult Run(
    const RecorderOptions & recorder_options,
    const std::function<void()> & pre_record = nullptr,
    const std::function<void(int)> & post_record = nullptr
  )
  {
    {
      std::lock_guard<std::mutex> lock(mutex_);
      if (IsActive()) {
        AWS_LOG_INFO(__func__, "Failed to run RosbagRecorder, recorder already active");
        return RosbagRecorderRunResult::SKIPPED;
      }
      AWS_LOG_INFO(__func__, "Starting a new RosbagRecorder session");
      static auto function_name = __func__;
      barrier_ = std::async(std::launch::async, [recorder_options, pre_record, post_record]
        {
          if (pre_record) {
            pre_record();
          }
          int exit_code;
          {
            T rosbag_recorder(recorder_options);
            exit_code = rosbag_recorder.Run();
          }
          if (exit_code != 0) {
            AWS_LOGSTREAM_ERROR(function_name, "RosbagRecorder encountered an error (code: " << exit_code << ')');
          }
          if (post_record) {
            post_record(exit_code);
          }
        }
      );
      return RosbagRecorderRunResult::STARTED;
    }
  }