Last change
on this file since 58519 was 58519, checked in by vboxsync, 9 years ago |
pr7179. DnD part has been changed.
|
-
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 |
|
---|
22 | HRESULT ThreadTask::createThread(PRTTHREAD pThread, RTTHREADTYPE enmType)
|
---|
23 | {
|
---|
24 | HRESULT rc = S_OK;
|
---|
25 | try
|
---|
26 | {
|
---|
27 | m_pThread = pThread;
|
---|
28 | int vrc = RTThreadCreate(m_pThread,
|
---|
29 | taskHandler,
|
---|
30 | (void *)this,
|
---|
31 | 0,
|
---|
32 | enmType,
|
---|
33 | 0,
|
---|
34 | this->getTaskName().c_str());
|
---|
35 | if (RT_FAILURE(vrc))
|
---|
36 | {
|
---|
37 | throw E_FAIL;
|
---|
38 | }
|
---|
39 | }
|
---|
40 | catch(HRESULT eRC)
|
---|
41 | {
|
---|
42 | rc = eRC;
|
---|
43 | delete this;
|
---|
44 | }
|
---|
45 | catch(std::exception& e)
|
---|
46 | {
|
---|
47 | rc = E_FAIL;
|
---|
48 | delete this;
|
---|
49 | }
|
---|
50 | catch(...)
|
---|
51 | {
|
---|
52 | rc = E_FAIL;
|
---|
53 | delete this;
|
---|
54 | }
|
---|
55 |
|
---|
56 | return rc;
|
---|
57 | }
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Static method that can get passed to RTThreadCreate to have a
|
---|
61 | * thread started for a Task.
|
---|
62 | */
|
---|
63 | /* static */ DECLCALLBACK(int) ThreadTask::taskHandler(RTTHREAD /* thread */, void *pvUser)
|
---|
64 | {
|
---|
65 | HRESULT rc = S_OK;
|
---|
66 | if(pvUser == NULL)
|
---|
67 | return VERR_INVALID_POINTER;
|
---|
68 |
|
---|
69 | ThreadTask *pTask = static_cast<ThreadTask *>(pvUser);
|
---|
70 | try
|
---|
71 | {
|
---|
72 | pTask->handler();
|
---|
73 | }
|
---|
74 | catch(HRESULT eRC)
|
---|
75 | {
|
---|
76 | rc = E_FAIL;
|
---|
77 | }
|
---|
78 | catch(std::exception& e)
|
---|
79 | {
|
---|
80 | rc = E_FAIL;
|
---|
81 | }
|
---|
82 | catch(...)
|
---|
83 | {
|
---|
84 | rc = E_FAIL;
|
---|
85 | }
|
---|
86 |
|
---|
87 | delete pTask;
|
---|
88 |
|
---|
89 | return 0;
|
---|
90 | }
|
---|
91 |
|
---|
92 | /*static*/ HRESULT ThreadTask::setErrorStatic(HRESULT aResultCode,
|
---|
93 | const Utf8Str &aText)
|
---|
94 | {
|
---|
95 | return aResultCode;
|
---|
96 | }
|
---|
97 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.