VirtualBox

source: vbox/trunk/src/VBox/Main/src-all/ThreadTask.cpp@ 58131

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

added svn properties to correct build on OSE machines

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.1 KB
Line 
1/** @file
2 * Implementation of ThreadTask
3 */
4
5/*
6 * Copyright (C) 2015 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#include <iprt/thread.h>
18
19#include "VirtualBoxBase.h"
20#include "ThreadTask.h"
21
22HRESULT ThreadTask::createThread()
23{
24 HRESULT rc = S_OK;
25 try
26 {
27 int vrc = RTThreadCreate(NULL,
28 taskHandler,
29 (void *)this,
30 0,
31 RTTHREADTYPE_MAIN_WORKER,
32 0,
33 this->getTaskName().c_str());
34 if (RT_FAILURE(vrc))
35 {
36 throw E_FAIL;
37 }
38 }
39 catch(HRESULT eRC)
40 {
41 rc = eRC;
42 delete this;
43 }
44 catch(std::exception& e)
45 {
46 rc = E_FAIL;
47 delete this;
48 }
49 catch(...)
50 {
51 rc = E_FAIL;
52 delete this;
53 }
54
55 return rc;
56}
57
58/**
59 * Static method that can get passed to RTThreadCreate to have a
60 * thread started for a Task.
61 */
62/* static */ DECLCALLBACK(int) ThreadTask::taskHandler(RTTHREAD /* thread */, void *pvUser)
63{
64 HRESULT rc = S_OK;
65 if(pvUser == NULL)
66 return VERR_INVALID_POINTER;
67
68 ThreadTask *pTask = static_cast<ThreadTask *>(pvUser);
69 try
70 {
71 pTask->handler();
72 }
73 catch(HRESULT eRC)
74 {
75 rc = E_FAIL;
76 }
77 catch(std::exception& e)
78 {
79 rc = E_FAIL;
80 }
81 catch(...)
82 {
83 rc = E_FAIL;
84 }
85
86 delete pTask;
87
88 return 0;
89}
90
91/*static*/ HRESULT ThreadTask::i_setErrorStatic(HRESULT aResultCode,
92 const Utf8Str &aText)
93{
94 return aResultCode;
95}
96
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