libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
thread_params_traits.hpp
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright © 2004 by J.M.McGuiness, coder@hussar.me.uk
3
**
4
** This library is free software; you can redistribute it and/or
5
** modify it under the terms of the GNU Lesser General Public
6
** License as published by the Free Software Foundation; either
7
** version 2.1 of the License, or (at your option) any later version.
8
**
9
** This library is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
** Lesser General Public License for more details.
13
**
14
** You should have received a copy of the GNU Lesser General Public
15
** License along with this library; if not, write to the Free Software
16
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*/
18
19
#
include
<
windows
.
h
>
20
21
namespace
jmmcg
{
namespace
LIBJMMCG_VER_NAMESPACE {
namespace
ppd {
22
23
/// A constant, suitably defined to be the appropraite API for the plaform on which the code is compiled, to allow one to be platform-agnostic.
24
static
constexpr
generic_traits::api_type platform_api=generic_traits::MS_Win32;
25
26
template
<>
27
class
thread_params
<
generic_traits
::
MS_Win32
> :
protected
non_assignable
{
28
public
:
29
static
constexpr
generic_traits
::
api_type
api_type
=
generic_traits
::
MS_Win32
;
30
31
typedef
HANDLE
handle_type
;
32
typedef
unsigned
int
pid_type
;
33
typedef
unsigned
int
tid_type
;
34
35
typedef
DWORD
processor_mask_type
;
36
37
typedef
DWORD
suspend_count
;
38
typedef
DWORD
suspend_period_ms
;
39
40
typedef
void
*
security_type
;
41
typedef
unsigned
stack_size_type
;
42
typedef
unsigned
core_work_fn_ret_t
;
43
typedef
void
*
core_work_fn_arg_t
;
44
typedef
core_work_fn_ret_t
(
__stdcall
core_work_fn_type)(
core_work_fn_arg_t
);
45
typedef
core_work_fn_arg_t
arglist_type
;
46
typedef
unsigned
initflag_type
;
47
48
enum
creation_flags
{
49
create_running
=0,
50
create_suspended
=
CREATE_SUSPENDED
51
};
52
53
enum
priority_type
{
54
lowest
=
THREAD_PRIORITY_LOWEST
,
55
idle
=
THREAD_PRIORITY_IDLE
,
56
below_normal
=
THREAD_PRIORITY_BELOW_NORMAL
,
57
normal
=
THREAD_PRIORITY_NORMAL
,
58
above_normal
=
THREAD_PRIORITY_ABOVE_NORMAL
,
59
highest
=
THREAD_PRIORITY_HIGHEST
,
60
time_critical
=
THREAD_PRIORITY_TIME_CRITICAL
,
61
unknown_priority
62
};
63
64
/**
65
Note that these states are in a specific order - the higher the number, the more severe any error.
66
*/
67
enum
states
{
68
active
=
STILL_ACTIVE
,
69
suspended
,
70
no_kernel_thread
,
///< This is not a failure - the thread may not be started yet, or may have exited.
71
get_exit_code_failure
,
72
// Error conditions now...
73
null_this_pointer
,
74
jmmcg_exception
,
75
stl_exception
,
76
unknown_exception
,
77
terminated
,
78
unknown
79
};
80
enum
thread_cancel_state
{
81
};
82
83
const
security_type
security
;
84
const
stack_size_type
stack_size
;
85
core_work_fn_type *
const
work_fn
;
86
arglist_type
arglist
;
87
88
handle_type
handle
;
89
tid_type
id
;
90
91
__stdcall
thread_params
(core_work_fn_type *
const
sa,
const
security_type
se,
const
stack_size_type
ss=0)
noexcept
(
true
)
92
:
security
(se),
stack_size
(ss),
work_fn
(sa),
arglist
(),
handle
(),
id
() {
93
assert(
work_fn
);
94
}
95
96
__stdcall
thread_params
(
const
thread_params
&tp)
noexcept
(
true
)
97
:
security
(tp
.
security
),
stack_size
(tp
.
stack_size
),
work_fn
(tp
.
work_fn
),
arglist
(tp
.
arglist
),
handle
(tp
.
handle
),
id
(tp
.
id
) {
98
}
99
100
tstring
to_string
(
void
)
const
{
101
tostringstream ss;
102
ss<<_T(
"API type: 0x"
)<<std::hex<<api_type
103
<<_T(
", stack size: 0x"
)<<std::dec<<stack_size
104
<<_T(
", work function ptr: 0x"
)<<std::hex<<work_fn
105
<<_T(
", argument list: 0x"
)<<std::hex<<arglist
106
<<_T(
", handle: 0x"
)<<std::hex<<handle
107
<<_T(
", ID: 0x"
)<<std::hex<<id;
108
return
ss.str();
109
}
110
};
111
112
} } }
experimental
NT-based
NTSpecific
thread_params_traits.hpp
Generated on Tue May 11 2021 17:31:28 for libjmmcg by
1.9.2