blob: 0dfd363cc8fb716b7ba4a04d2f3de9208a2f6118 [file] [log] [blame]
Andrew Walbran3d2c1972020-04-07 12:24:26 +01001//===-- HostNativeThreadBase.h ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
Olivier Deprezf4ef2d02021-04-20 13:36:24 +02009#ifndef LLDB_HOST_HOSTNATIVETHREADBASE_H
10#define LLDB_HOST_HOSTNATIVETHREADBASE_H
Andrew Walbran3d2c1972020-04-07 12:24:26 +010011
12#include "lldb/Utility/Status.h"
13#include "lldb/lldb-defines.h"
14#include "lldb/lldb-types.h"
15
16namespace lldb_private {
17
18#if defined(_WIN32)
19#define THREAD_ROUTINE __stdcall
20#else
21#define THREAD_ROUTINE
22#endif
23
24class HostNativeThreadBase {
25 friend class ThreadLauncher;
Olivier Deprezf4ef2d02021-04-20 13:36:24 +020026 HostNativeThreadBase(const HostNativeThreadBase &) = delete;
27 const HostNativeThreadBase &operator=(const HostNativeThreadBase &) = delete;
Andrew Walbran3d2c1972020-04-07 12:24:26 +010028
29public:
30 HostNativeThreadBase();
31 explicit HostNativeThreadBase(lldb::thread_t thread);
32 virtual ~HostNativeThreadBase() {}
33
34 virtual Status Join(lldb::thread_result_t *result) = 0;
35 virtual Status Cancel() = 0;
36 virtual bool IsJoinable() const;
37 virtual void Reset();
38 virtual bool EqualsThread(lldb::thread_t thread) const;
39 lldb::thread_t Release();
40
41 lldb::thread_t GetSystemHandle() const;
42 lldb::thread_result_t GetResult() const;
43
44protected:
45 static lldb::thread_result_t THREAD_ROUTINE
46 ThreadCreateTrampoline(lldb::thread_arg_t arg);
47
48 lldb::thread_t m_thread;
49 lldb::thread_result_t m_result;
50};
51}
52
53#endif