// Copyright 2024 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.

#include "modules/worker/test_worker.h"

#include "pw_assert/check.h"

namespace sense::internal {

GenericTestWorker::GenericTestWorker(pw::work_queue::WorkQueue& work_queue)
    : work_queue_(&work_queue) {}

void GenericTestWorker::Start() {
  work_thread_ = pw::thread::Thread(context_.options(), *work_queue_);
}

void GenericTestWorker::RunOnce(pw::Function<void()>&& work) {
  // TODO: CHECK-ing this error causes flakes in the state manager tests due to
  // their repeated use of the work queue. Investigate whether that can be
  // resolved.
  work_queue_->PushWork(std::move(work)).IgnoreError();
}

GenericTestWorker::~GenericTestWorker() {
  PW_CHECK_PTR_EQ(
      work_queue_,
      nullptr,
      "`TestWorker::Stop` must be called before the test completes.");
}

void GenericTestWorker::Stop() {
  work_queue_->RequestStop();
  work_thread_.join();
  work_queue_ = nullptr;
}

}  // namespace sense::internal
