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<>
28  public:
30 
32  typedef unsigned int pid_type;
33  typedef unsigned int tid_type;
34 
36 
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);
46  typedef unsigned initflag_type;
47 
51  };
52 
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 {
70  no_kernel_thread, ///< This is not a failure - the thread may not be started yet, or may have exited.
72  // Error conditions now...
78  unknown
79  };
81  };
82 
85  core_work_fn_type * const work_fn;
87 
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)
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 } } }