Zen API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kThread.h
Go to the documentation of this file.
1 
10 #ifndef K_API_THREAD_H
11 #define K_API_THREAD_H
12 
13 #include <kApi/kApiDef.h>
14 
16 typedef kStatus(kCall* kThreadFx)(kPointer context);
17 
18 #include <kApi/Threads/kThread.x.h>
19 
26 //typedef kObject kThread; --forward-declared in kApiDef.x.h
27 
35 
52 kFx(kStatus) kThread_Sleep(k64u duration);
53 
64 kFx(kStatus) kThread_SleepAtLeast(k64u duration);
65 
73 
81 
89 
98 
107 
115 
128 kFx(kStatus) kThread_Construct(kThread* thread, kAlloc allocator);
129 
144 kFx(kStatus) kThread_SetName(kThread thread, const kChar* name);
145 
153 kFx(const kChar*) kThread_Name(kThread thread);
154 
197 kFx(kStatus) kThread_SetPriority(kThread thread, kThreadPriorityClass priorityClass, k32s priorityOffset);
198 
213 kFx(kStatus) kThread_SetAffinity(kThread thread, kBitArray affinity);
214 
228 kFx(kStatus) kThread_Start(kThread thread, kThreadFx function, kPointer context);
229 
241 #if defined(K_CPP)
242 kInlineFx(kStatus) kThread_Start(kThread thread, kThreadFx function, kPointer context, const kChar* name)
243 {
244  kObj(kThread, thread);
245 
246  kCheck(kThread_SetName(thread, name));
247 
248  return kThread_Start(thread, function, context);
249 }
250 #endif
251 
265 #if defined(K_CPP)
266 kInlineFx(kStatus) kThread_Start(kThread thread, kThreadFx function, kPointer context, const kChar* name,
267  kThreadPriorityClass priorityClass, k32s priorityOffset)
268 {
269  kObj(kThread, thread);
270 
271  kCheck(kThread_SetName(thread, name));
272  kCheck(kThread_SetPriority(thread, priorityClass, priorityOffset));
273 
274  return kThread_Start(thread, function, context);
275 }
276 #endif
277 
287 kFx(kStatus) kThread_Join(kThread thread, k64u timeout, kStatus* exitCode);
288 
300 kFx(kThreadId) kThread_Id(kThread thread);
301 
311 kFx(kBool) kThread_IsSelf(kThread other);
312 
313 #endif
kStatus kThread_Start(kThread thread, kThreadFx function, kPointer context)
Begins executing a thread using the specified callback function.
kStatus kThread_SleepAtLeast(k64u duration)
Causes the current thread to yield control for at least the specified duration.
Represents a unique thread identifier.
Represents a 64-bit unsigned integer.
Represents a void pointer.
kThreadId kThread_Id(kThread thread)
Gets a unique identifier representing the thread.
Represents an unsigned integer that can store a pointer address.
Abstract base class for memory allocator types.
#define kCheck(EXPRESSION)
Executes a return statement if the given expression is not kOK.
Definition: kApiDef.h:561
kBool kThread_IsSelf(kThread other)
Reports whether the specified thread is the currently executing thread.
#define kInlineFx(TYPE)
Inline method declaration helper.
Definition: kApiDef.h:26
Represents a single unit (byte) in a UTF-8 character.
Represents a thread.
typedef kStatus(kCall *kMsgQueueDropFx)(kPointer receiver
Defines the signature of a callback function to handle dropped items.
k32s kThread_MaxPriorityOffset(kThreadPriorityClass priorityClass)
Reports the maximum supported priority offset for the specified priority class.
kStatus kThread_Sleep(k64u duration)
Causes the current thread to yield control for approximately the specified duration.
Represents a 1D array of bits.
kStatus kThread_SetAffinity(kThread thread, kBitArray affinity)
Sets the CPUs with which the thread should have affinity.
#define kObj(TypeName_T, T_object)
Declares a local "obj" (this-pointer) variable and initializes it from a type-checked object handle...
Definition: kApiDef.h:3383
kSize kThread_ProcessorCount()
Reports the number of logical processors in the current system.
kStatus kThread_SetName(kThread thread, const kChar *name)
Sets the name of the thread.
Core Zen type declarations.
Represents a 32-bit signed integer.
k32s kThread_MinPriorityOffset(kThreadPriorityClass priorityClass)
Reports the minimum supported priority offset for the specified priority class.
kThreadPriorityClass kThread_MaxPriorityClass()
Reports the maximum supported priority class.
kThreadPriorityClass kThread_MinPriorityClass()
Reports the minimum supported priority class.
kStatus(kCall * kThreadFx)(kPointer context)
Thread entry-point signature; used by kThread_Start.
Definition: kThread.h:16
Represents an error code.
Represents a thread priority class.
kThreadId kThread_CurrentId()
Gets a unique identifier that represents the currently executing thread.
#define kCall
kApi standard function calling convention.
Definition: kApiDef.h:15
kStatus kThread_Join(kThread thread, k64u timeout, kStatus *exitCode)
Blocks until the thread exits, or until a timeout occurs.
kStatus kThread_Construct(kThread *thread, kAlloc allocator)
Constructs a kThread object.
const kChar * kThread_Name(kThread thread)
Reports the name associated with the thread.
kStatus kThread_SetPriority(kThread thread, kThreadPriorityClass priorityClass, k32s priorityOffset)
Sets the priority associated with the thread.
Represents a boolean value.
kBool kThread_CanSetAffinty()
Reports whether core affinity can be set.