VirtualBox

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

Last change on this file since 87093 was 82968, checked in by vboxsync, 5 years 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.6 KB
Line 
1/** @file
2 * VirtualBox ThreadTask class definition
3 */
4
5/*
6 * Copyright (C) 2015-2020 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 */
16
17#ifndef MAIN_INCLUDED_ThreadTask_h
18#define MAIN_INCLUDED_ThreadTask_h
19#ifndef RT_WITHOUT_PRAGMA_ONCE
20# pragma once
21#endif
22
23#include "VBox/com/string.h"
24
25/**
26 * The class ThreadVoidData is used as a base class for any data which we want to pass into a thread
27 */
28struct ThreadVoidData
29{
30public:
31 ThreadVoidData() { }
32 virtual ~ThreadVoidData() { }
33};
34
35
36class ThreadTask
37{
38public:
39 ThreadTask(const Utf8Str &t)
40 : m_strTaskName(t)
41 , mAsync(false)
42 { }
43
44 virtual ~ThreadTask()
45 { }
46
47 HRESULT createThread(void);
48 HRESULT createThreadWithType(RTTHREADTYPE enmType);
49
50 inline Utf8Str getTaskName() const { return m_strTaskName; }
51 bool isAsync() { return mAsync; }
52
53protected:
54 HRESULT createThreadInternal(RTTHREADTYPE enmType);
55 static DECLCALLBACK(int) taskHandlerThreadProc(RTTHREAD thread, void *pvUser);
56
57 ThreadTask() : m_strTaskName("GenericTask")
58 { }
59
60 Utf8Str m_strTaskName;
61 bool mAsync;
62
63private:
64 virtual void handler() = 0;
65};
66
67#endif /* !MAIN_INCLUDED_ThreadTask_h */
68
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