905318c724
This reverts commit2221f0909b
. Reason for revert: fix in patchset 2 Original change's description: > Revert "cppgc: Provide jobs support through DefaultPlatform and TestPlatform" > > This reverts commit22c0fc8f2e
. > > Reason for revert: https://ci.chromium.org/p/v8/builders/ci/V8%20Linux%20gcc/8712? > > Original change's description: > > cppgc: Provide jobs support through DefaultPlatform and TestPlatform > > > > This CL extends cppgc::DefaultPlatform and TestPlatform to emulate > > jobs using std::thread and v8::base::Thread respectively. > > Jobs using these platform do not yield unless the job as been > > cancelled. Additionally, the job priority is ignored. > > > > Bug: chromium:1056170 > > Change-Id: I72db1eef410d2be3d3e5ea7d4ece9e5584a451f2 > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2416378 > > Commit-Queue: Omer Katz <omerkatz@chromium.org> > > Reviewed-by: Anton Bikineev <bikineev@chromium.org> > > Reviewed-by: Michael Lippautz <mlippautz@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#70139} > > TBR=mlippautz@chromium.org,bikineev@chromium.org,omerkatz@chromium.org > > Change-Id: Ic29235e3ab78a1b515a5b14b808e116a1ccffc0f > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:1056170 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2432087 > Reviewed-by: Francis McCabe <fgm@chromium.org> > Commit-Queue: Francis McCabe <fgm@chromium.org> > Cr-Commit-Position: refs/heads/master@{#70142} # Not skipping CQ checks because this is a reland. Bug: chromium:1056170 Change-Id: Iaa8312da759ab97f646a9fb6144462a115393b5f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2431666 Reviewed-by: Anton Bikineev <bikineev@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Commit-Queue: Omer Katz <omerkatz@chromium.org> Cr-Commit-Position: refs/heads/master@{#70150}
85 lines
2.6 KiB
C++
85 lines
2.6 KiB
C++
// 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 INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
|
|
#define INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
#include "cppgc/platform.h"
|
|
#include "v8config.h" // NOLINT(build/include_directory)
|
|
|
|
namespace cppgc {
|
|
|
|
namespace internal {
|
|
class DefaultJob;
|
|
} // namespace internal
|
|
|
|
/**
|
|
* Default task runner implementation. Keep posted tasks in a list that can be
|
|
* processed by calling RunSingleTask() or RunUntilIdle().
|
|
*/
|
|
class V8_EXPORT DefaultTaskRunner final : public cppgc::TaskRunner {
|
|
public:
|
|
DefaultTaskRunner() = default;
|
|
|
|
DefaultTaskRunner(const DefaultTaskRunner&) = delete;
|
|
DefaultTaskRunner& operator=(const DefaultTaskRunner&) = delete;
|
|
|
|
void PostTask(std::unique_ptr<cppgc::Task> task) override;
|
|
void PostDelayedTask(std::unique_ptr<cppgc::Task> task, double) override;
|
|
|
|
bool NonNestableTasksEnabled() const final { return false; }
|
|
bool NonNestableDelayedTasksEnabled() const final { return false; }
|
|
void PostNonNestableTask(std::unique_ptr<cppgc::Task> task) override;
|
|
void PostNonNestableDelayedTask(std::unique_ptr<cppgc::Task> task,
|
|
double) override;
|
|
|
|
void PostIdleTask(std::unique_ptr<cppgc::IdleTask> task) override;
|
|
bool IdleTasksEnabled() override { return true; }
|
|
|
|
bool RunSingleTask();
|
|
bool RunSingleIdleTask(double duration_in_seconds);
|
|
|
|
void RunUntilIdle();
|
|
|
|
private:
|
|
std::vector<std::unique_ptr<cppgc::Task>> tasks_;
|
|
std::vector<std::unique_ptr<cppgc::IdleTask>> idle_tasks_;
|
|
};
|
|
|
|
/**
|
|
* Default platform implementation that uses std::thread for spawning job tasks.
|
|
*/
|
|
class V8_EXPORT DefaultPlatform final : public Platform {
|
|
public:
|
|
DefaultPlatform();
|
|
~DefaultPlatform() noexcept override;
|
|
|
|
cppgc::PageAllocator* GetPageAllocator() final;
|
|
|
|
double MonotonicallyIncreasingTime() final;
|
|
|
|
std::shared_ptr<cppgc::TaskRunner> GetForegroundTaskRunner() final;
|
|
|
|
// DefaultPlatform does not support job priorities. All jobs would be
|
|
// assigned the same priority regardless of the cppgc::TaskPriority parameter.
|
|
std::unique_ptr<cppgc::JobHandle> PostJob(
|
|
cppgc::TaskPriority priority,
|
|
std::unique_ptr<cppgc::JobTask> job_task) final;
|
|
|
|
void WaitAllForegroundTasks();
|
|
void WaitAllBackgroundTasks();
|
|
|
|
private:
|
|
std::unique_ptr<PageAllocator> page_allocator_;
|
|
std::shared_ptr<DefaultTaskRunner> foreground_task_runner_;
|
|
std::vector<std::shared_ptr<internal::DefaultJob>> jobs_;
|
|
};
|
|
|
|
} // namespace cppgc
|
|
|
|
#endif // INCLUDE_CPPGC_DEFAULT_PLATFORM_H_
|