chromium/codelabs/threading_and_scheduling/04-multiple-threads.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "base/message_loop/message_pump.h"
#include "base/run_loop.h"
#include "base/task/sequence_manager/sequence_manager.h"
#include "base/task/sequence_manager/sequence_manager_impl.h"  // For IOThreadDelegate.
#include "base/task/sequence_manager/task_queue.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"

// For this example, these are global so that each task running on each thread
// can easily grab the *other* thread's task runner to post continuation tasks
// to.
static scoped_refptr<base::SingleThreadTaskRunner> g_main_thread_task_runner;
static scoped_refptr<base::SingleThreadTaskRunner> g_io_thread_task_runner;

void RunOnIOThread();

void RunOnUIThread() {}

void RunOnIOThread() {}

// In this example we're simulating Chromium's UI/IO thread architecture in a
// simplified way. The `IOThreadDelegate` represents the physical "IO" thread
// that each Chromium process has, running alongside the main thread. It is
// similar to `content::BrowserIOThreadDelegate`, for example.
class IOThreadDelegate : public base::Thread::Delegate {};

int main() {}