cheshirekow  v0.1.0
thread_attr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Josh Bialkowski (jbialk@mit.edu)
3  *
4  * This file is part of cpp-pthreads.
5  *
6  * cpp-pthreads is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * cpp-pthreads is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with cpp-pthreads. If not, see <http://www.gnu.org/licenses/>.
18  */
27 #ifndef CPP_PTHREADS_THREADATTR_H_
28 #define CPP_PTHREADS_THREADATTR_H_
29 
30 #include <pthread.h>
31 
32 #include <cstdarg>
33 
34 #include <cpp_pthreads/attr.h>
35 #include <cpp_pthreads/enums.h>
36 #include <cpp_pthreads/thread.h>
37 
38 namespace pthreads {
39 
43 
47 
49 struct Stack {
50  void* addr;
51  std::size_t size;
52 
53  Stack(void* addr = 0, std::size_t size = 0)
54  : addr(addr),
55  size(size) {
56  }
57 };
58 
60 extern const Access<Thread, DetachState> DETACH_STATE;
61 
63 extern const Access<Thread, InheritSched> INHERIT_SCHED;
64 
66 extern const Access<Thread, SchedPolicy> SCHED_POLICY;
67 
69 extern const Access<Thread, Scope> SCOPE;
70 
72 extern const Access<Thread, GuardSize> GUARD_SIZE;
73 
76 extern const Access<Thread, Stack> STACK;
77 
79 extern const Access<Thread, StackSize> STACK_SIZE;
80 
83 template<>
84 struct AttrType<Thread> {
85  typedef pthread_attr_t type;
86 };
87 
88 }
89 
90 #endif // THREADATTR_H_
const Access< Thread, SchedPolicy > SCHED_POLICY
provides access to the schedpolicy field of a pthread_attr_t
const Access< Thread, StackSize > STACK_SIZE
provides access to the stacksize field of a pthread_attr_t
template used to resolve the pthreads_xxx_t object corresponding to the Attr<Base> object ...
Definition: attr.h:42
Stack(void *addr=0, std::size_t size=0)
Definition: thread_attr.h:53
const Access< Thread, GuardSize > GUARD_SIZE
provides access to the guardsize field of a pthread_attr_t
A thread... presumably you know what this is.
Definition: thread.h:44
const Access< Thread, Scope > SCOPE
provides access to the scope field of a pthread_attr_t
Provides a unique type that acts like a native type.
Definition: attr.h:261
TypeWrap< std::size_t, 0 > GuardSize
A unique type which acts just like size_t but is distinct in the eyes of the compiler.
Definition: thread_attr.h:42
TypeWrap< std::size_t, 1 > StackSize
A unique type which acts just like size_t but is distinct in the eyes of the compiler.
Definition: thread_attr.h:46
const Access< Thread, DetachState > DETACH_STATE
provides access to the detachstate field of a pthread_attr_t
Simply encapsulates the stack address and size in a single object.
Definition: thread_attr.h:49
const Access< Thread, InheritSched > INHERIT_SCHED
provides access to the inheritsched field of a pthread_attr_t
const Access< Thread, Stack > STACK
provides access to the stack field of a pthread_attr_t, including stack address and size ...
std::size_t size
Definition: thread_attr.h:51