ARGOBOTS  1.1
abti_thread.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #ifndef ABTI_THREAD_H_INCLUDED
7 #define ABTI_THREAD_H_INCLUDED
8 
10 {
11 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
12  ABTI_thread *p_thread;
13  if (thread == ABT_THREAD_NULL || thread == ABT_TASK_NULL) {
14  p_thread = NULL;
15  } else {
16  p_thread = (ABTI_thread *)thread;
17  }
18  return p_thread;
19 #else
20  return (ABTI_thread *)thread;
21 #endif
22 }
23 
25 {
26 #ifndef ABT_CONFIG_DISABLE_ERROR_CHECK
27  ABT_thread h_thread;
28  if (p_thread == NULL) {
29  h_thread = ABT_THREAD_NULL;
30  } else {
31  h_thread = (ABT_thread)p_thread;
32  }
33  return h_thread;
34 #else
35  return (ABT_thread)p_thread;
36 #endif
37 }
38 
39 /* Inlined functions for User-level Thread (ULT) */
40 
42 {
43  if (type & ABTI_THREAD_TYPE_YIELDABLE) {
44  return ABT_UNIT_TYPE_THREAD;
45  } else if (type == ABTI_THREAD_TYPE_EXT) {
46  return ABT_UNIT_TYPE_EXT;
47  } else {
48  return ABT_UNIT_TYPE_TASK;
49  }
50 }
51 
53 {
54  ABTI_STATIC_ASSERT(offsetof(ABTI_ythread, thread) == 0);
55  return (ABTI_ythread *)p_thread;
56 }
57 
58 static inline ABTI_ythread *
60 {
61  if (p_thread->type & ABTI_THREAD_TYPE_YIELDABLE) {
62  return ABTI_thread_get_ythread(p_thread);
63  } else {
64  return NULL;
65  }
66 }
67 
68 static inline void ABTI_thread_set_request(ABTI_thread *p_thread, uint32_t req)
69 {
70  ABTD_atomic_fetch_or_uint32(&p_thread->request, req);
71 }
72 
73 static inline void ABTI_thread_unset_request(ABTI_thread *p_thread,
74  uint32_t req)
75 {
76  ABTD_atomic_fetch_and_uint32(&p_thread->request, ~req);
77 }
78 
79 #endif /* ABTI_THREAD_H_INCLUDED */
ABT_thread
struct ABT_thread_opaque * ABT_thread
Work unit handle type.
Definition: abt.h:890
ABTI_thread::type
ABTI_thread_type type
Definition: abti.h:375
ABTI_THREAD_TYPE_YIELDABLE
#define ABTI_THREAD_TYPE_YIELDABLE
Definition: abti.h:86
ABTI_thread::request
ABTD_atomic_uint32 request
Definition: abti.h:382
ABTI_thread_get_ythread
static ABTI_ythread * ABTI_thread_get_ythread(ABTI_thread *p_thread)
Definition: abti_thread.h:52
ABT_THREAD_NULL
#define ABT_THREAD_NULL
Definition: abt.h:1062
ABTI_thread_get_handle
static ABT_thread ABTI_thread_get_handle(ABTI_thread *p_thread)
Definition: abti_thread.h:24
ABTI_thread
Definition: abti.h:371
ABTI_THREAD_TYPE_EXT
#define ABTI_THREAD_TYPE_EXT
Definition: abti.h:81
ABTI_thread_type_get_type
static ABT_unit_type ABTI_thread_type_get_type(ABTI_thread_type type)
Definition: abti_thread.h:41
ABTI_thread_get_ythread_or_null
static ABTI_ythread * ABTI_thread_get_ythread_or_null(ABTI_thread *p_thread)
Definition: abti_thread.h:59
ABT_unit_type
ABT_unit_type
Type of a work unit for scheduling.
Definition: abt.h:548
ABTI_STATIC_ASSERT
#define ABTI_STATIC_ASSERT(cond)
Definition: abti_error.h:19
ABT_TASK_NULL
#define ABT_TASK_NULL
Definition: abt.h:1064
ABTI_thread_type
uint32_t ABTI_thread_type
Definition: abti.h:126
ABTI_ythread
Definition: abti.h:406
ABTD_atomic_fetch_and_uint32
static uint32_t ABTD_atomic_fetch_and_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:573
ABT_UNIT_TYPE_THREAD
@ ABT_UNIT_TYPE_THREAD
Definition: abt.h:550
ABTD_atomic_fetch_or_uint32
static uint32_t ABTD_atomic_fetch_or_uint32(ABTD_atomic_uint32 *ptr, uint32_t v)
Definition: abtd_atomic.h:631
ABT_UNIT_TYPE_TASK
@ ABT_UNIT_TYPE_TASK
Definition: abt.h:556
ABTI_thread_unset_request
static void ABTI_thread_unset_request(ABTI_thread *p_thread, uint32_t req)
Definition: abti_thread.h:73
ABTI_thread_get_ptr
static ABTI_thread * ABTI_thread_get_ptr(ABT_thread thread)
Definition: abti_thread.h:9
ABT_UNIT_TYPE_EXT
@ ABT_UNIT_TYPE_EXT
Definition: abt.h:560
ABTI_thread_set_request
static void ABTI_thread_set_request(ABTI_thread *p_thread, uint32_t req)
Definition: abti_thread.h:68