2020-05-26 14:40:57 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_UNITTESTS_HEAP_CPPGC_TEST_PLATFORM_H_
|
|
|
|
#define V8_UNITTESTS_HEAP_CPPGC_TEST_PLATFORM_H_
|
|
|
|
|
2020-10-08 11:16:20 +00:00
|
|
|
#include "include/cppgc/default-platform.h"
|
|
|
|
#include "src/base/compiler-specific.h"
|
2020-05-26 14:40:57 +00:00
|
|
|
|
|
|
|
namespace cppgc {
|
|
|
|
namespace internal {
|
|
|
|
namespace testing {
|
|
|
|
|
2020-10-08 11:16:20 +00:00
|
|
|
class TestPlatform : public DefaultPlatform {
|
2020-05-26 14:40:57 +00:00
|
|
|
public:
|
2020-11-26 10:08:27 +00:00
|
|
|
class V8_NODISCARD DisableBackgroundTasksScope {
|
2020-05-26 14:40:57 +00:00
|
|
|
public:
|
|
|
|
explicit DisableBackgroundTasksScope(TestPlatform*);
|
|
|
|
~DisableBackgroundTasksScope() V8_NOEXCEPT;
|
|
|
|
|
|
|
|
private:
|
|
|
|
TestPlatform* platform_;
|
|
|
|
};
|
|
|
|
|
2020-11-19 12:27:35 +00:00
|
|
|
TestPlatform(
|
|
|
|
std::unique_ptr<v8::TracingController> tracing_controller = nullptr);
|
2020-05-26 14:40:57 +00:00
|
|
|
|
2020-09-25 18:04:34 +00:00
|
|
|
std::unique_ptr<cppgc::JobHandle> PostJob(
|
2020-10-08 11:16:20 +00:00
|
|
|
cppgc::TaskPriority priority,
|
|
|
|
std::unique_ptr<cppgc::JobTask> job_task) final;
|
2020-05-26 14:40:57 +00:00
|
|
|
|
2020-10-08 11:16:20 +00:00
|
|
|
void RunAllForegroundTasks();
|
2020-05-26 14:40:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool AreBackgroundTasksDisabled() const {
|
|
|
|
return disabled_background_tasks_ > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t disabled_background_tasks_ = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace testing
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace cppgc
|
|
|
|
|
|
|
|
#endif // V8_UNITTESTS_HEAP_CPPGC_TEST_PLATFORM_H_
|