VirtualBox

source: vbox/trunk/src/VBox/Main/include/ThreadTask.h@ 106262

Last change on this file since 106262 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1/** @file
2 * VirtualBox ThreadTask class definition
3 */
4
5/*
6 * Copyright (C) 2015-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * SPDX-License-Identifier: GPL-3.0-only
25 */
26
27#ifndef MAIN_INCLUDED_ThreadTask_h
28#define MAIN_INCLUDED_ThreadTask_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33#include "VBox/com/string.h"
34
35/**
36 * The class ThreadVoidData is used as a base class for any data which we want to pass into a thread
37 */
38struct ThreadVoidData
39{
40public:
41 ThreadVoidData() { }
42 virtual ~ThreadVoidData() { }
43};
44
45
46class ThreadTask
47{
48public:
49 ThreadTask(const Utf8Str &t)
50 : m_strTaskName(t)
51 , mAsync(false)
52 { }
53
54 virtual ~ThreadTask()
55 { }
56
57 HRESULT createThread(void);
58 HRESULT createThreadWithType(RTTHREADTYPE enmType);
59
60 inline Utf8Str getTaskName() const { return m_strTaskName; }
61 bool isAsync() { return mAsync; }
62
63protected:
64 HRESULT createThreadInternal(RTTHREADTYPE enmType);
65 static DECLCALLBACK(int) taskHandlerThreadProc(RTTHREAD thread, void *pvUser);
66
67 ThreadTask() : m_strTaskName("GenericTask")
68 { }
69
70 Utf8Str m_strTaskName;
71 bool mAsync;
72
73private:
74 virtual void handler() = 0;
75};
76
77#endif /* !MAIN_INCLUDED_ThreadTask_h */
78
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette