VirtualBox

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

Last change on this file since 63182 was 63182, checked in by vboxsync, 9 years ago

ThreadTask: split createThread up into three methods to avoid having to pass NULL all the time when the type needs specifying. Also, explictly marked the racy variant.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1/** @file
2 * VirtualBox ThreadTask class definition
3 */
4
5/*
6 * Copyright (C) 2015-2016 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.215389.xyz. 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 ____H_THREADTASK
18#define ____H_THREADTASK
19
20#include "VBox/com/string.h"
21
22struct ThreadVoidData
23{
24/*
25 * The class ThreadVoidData is used as a base class for any data which we want to pass into a thread
26 */
27public:
28 ThreadVoidData(){};
29 virtual ~ThreadVoidData(){};
30};
31
32class ThreadTask
33{
34public:
35 ThreadTask(const Utf8Str &t) : m_pThread(NULL), m_strTaskName(t)
36 { };
37
38 virtual ~ThreadTask()
39 { };
40
41 HRESULT createThread(void);
42 HRESULT createThreadWithType(RTTHREADTYPE enmType);
43 HRESULT createThreadWithRaceCondition(PRTTHREAD pThread);
44
45 virtual void handler() = 0;
46 inline Utf8Str getTaskName() const {return m_strTaskName;};
47
48protected:
49 HRESULT createThreadInternal(RTTHREADTYPE enmType, PRTTHREAD pThread);
50 static DECLCALLBACK(int) taskHandlerThreadProc(RTTHREAD thread, void *pvUser);
51
52 ThreadTask():m_pThread(NULL), m_strTaskName("GenericTask"){};
53
54 PRTTHREAD m_pThread;
55 Utf8Str m_strTaskName;
56};
57
58#endif
59
Note: See TracBrowser for help on using the repository browser.

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