chromium/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/threading/platform_thread.h

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

// WARNING: You should *NOT* be using this class directly.  PlatformThread is
// the low-level platform-specific abstraction to the OS's threading interface.
// You should instead be using a message-loop driven Thread, see thread.h.

#ifndef PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREADING_PLATFORM_THREAD_H_
#define PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREADING_PLATFORM_THREAD_H_

#include <cstddef>
#include <iosfwd>

#include "partition_alloc/build_config.h"
#include "partition_alloc/partition_alloc_base/component_export.h"
#include "partition_alloc/partition_alloc_base/threading/platform_thread_ref.h"
#include "partition_alloc/partition_alloc_base/time/time.h"

#if PA_BUILDFLAG(IS_WIN)
#include "partition_alloc/partition_alloc_base/win/windows_types.h"
#elif PA_BUILDFLAG(IS_FUCHSIA)
#include <zircon/types.h>
#elif PA_BUILDFLAG(IS_APPLE)
#include <mach/mach_types.h>
#elif PA_BUILDFLAG(IS_POSIX)
#include <pthread.h>
#include <unistd.h>
#endif

namespace partition_alloc::internal::base {

// Used for logging. Always an integer value.
#if PA_BUILDFLAG(IS_WIN)
typedef DWORD PlatformThreadId;
#elif PA_BUILDFLAG(IS_FUCHSIA)
typedef zx_handle_t PlatformThreadId;
#elif PA_BUILDFLAG(IS_APPLE)
typedef mach_port_t PlatformThreadId;
#elif PA_BUILDFLAG(IS_POSIX)
PlatformThreadId;
#endif

// Used to operate on threads.
class PlatformThreadHandle {};

const PlatformThreadId kInvalidThreadId(0);

SetThreadNameProc;

// A namespace for low-level thread functions.
class PA_COMPONENT_EXPORT(PARTITION_ALLOC_BASE) PlatformThread {};

}  // namespace partition_alloc::internal::base

#endif  // PARTITION_ALLOC_PARTITION_ALLOC_BASE_THREADING_PLATFORM_THREAD_H_