33 #ifndef _ODE_THREADING_BASE_H_
34 #define _ODE_THREADING_BASE_H_
37 #include <ode/threading.h>
45 virtual const dxThreadingFunctionsInfo *RetrieveThreadingDefaultImpl(dThreadingImplementationID &out_default_impl) = 0;
53 m_default_impl_provider(NULL),
54 m_functions_info(NULL),
55 m_threading_impl(NULL)
65 dAASSERT((functions_info == NULL) == (threading_impl == NULL));
67 m_functions_info = functions_info;
68 m_threading_impl = threading_impl;
72 dMutexGroupID AllocMutexGroup(dmutexindex_t Mutex_count,
const char *
const *Mutex_names_ptr)
const
74 dThreadingImplementationID impl;
76 return functions->alloc_mutex_group(impl, Mutex_count, Mutex_names_ptr);
79 void FreeMutexGroup(dMutexGroupID mutex_group)
const
81 dThreadingImplementationID impl;
83 functions->free_mutex_group(impl, mutex_group);
86 void LockMutexGroupMutex(dMutexGroupID mutex_group, dmutexindex_t mutex_index)
const
88 dThreadingImplementationID impl;
90 functions->lock_group_mutex(impl, mutex_group, mutex_index);
100 void UnlockMutexGroupMutex(dMutexGroupID mutex_group, dmutexindex_t mutex_index)
const
102 dThreadingImplementationID impl;
104 functions->unlock_group_mutex(impl, mutex_group, mutex_index);
107 dCallWaitID AllocThreadedCallWait()
const
109 dThreadingImplementationID impl;
111 return functions->alloc_call_wait(impl);
114 void ResetThreadedCallWait(dCallWaitID call_wait)
const
116 dThreadingImplementationID impl;
118 functions->reset_call_wait(impl, call_wait);
121 void FreeThreadedCallWait(dCallWaitID call_wait)
const
123 dThreadingImplementationID impl;
125 functions->free_call_wait(impl, call_wait);
128 void PostThreadedCall(
int *out_summary_fault,
129 dCallReleaseeID *out_post_releasee, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee,
130 dCallWaitID call_wait,
131 dThreadedCallFunction *call_func,
void *call_context, dcallindex_t instance_index,
132 const char *call_name)
const
134 dThreadingImplementationID impl;
136 functions->post_call(impl, out_summary_fault, out_post_releasee, dependencies_count, dependent_releasee, call_wait, call_func, call_context, instance_index, call_name);
139 void AlterThreadedCallDependenciesCount(dCallReleaseeID target_releasee,
140 ddependencychange_t dependencies_count_change)
const
142 dThreadingImplementationID impl;
144 functions->alter_call_dependencies_count(impl, target_releasee, dependencies_count_change);
147 void WaitThreadedCallExclusively(
int *out_wait_status,
149 const char *wait_name)
const
151 dThreadingImplementationID impl;
153 functions->wait_call(impl, out_wait_status, call_wait, timeout_time_ptr, wait_name);
154 functions->reset_call_wait(impl, call_wait);
157 void WaitThreadedCallCollectively(
int *out_wait_status,
159 const char *wait_name)
const
161 dThreadingImplementationID impl;
163 functions->wait_call(impl, out_wait_status, call_wait, timeout_time_ptr, wait_name);
166 unsigned RetrieveThreadingThreadCount()
const
168 dThreadingImplementationID impl;
170 return functions->retrieve_thread_count(impl);
173 bool PreallocateResourcesForThreadedCalls(
unsigned max_simultaneous_calls_estimate)
const
175 dThreadingImplementationID impl;
177 return functions->preallocate_resources_for_calls(impl, max_simultaneous_calls_estimate) != 0;
181 void PostThreadedCallsGroup(
int *out_summary_fault,
182 ddependencycount_t member_count, dCallReleaseeID dependent_releasee,
183 dThreadedCallFunction *call_func,
void *call_context,
184 const char *call_name)
const;
185 void PostThreadedCallForUnawareReleasee(
int *out_summary_fault,
186 dCallReleaseeID *out_post_releasee, ddependencycount_t dependencies_count, dCallReleaseeID dependent_releasee,
187 dCallWaitID call_wait,
188 dThreadedCallFunction *call_func,
void *call_context, dcallindex_t instance_index,
189 const char *call_name)
const;
196 dThreadingImplementationID GetThreadingImpl()
const {
return m_threading_impl; }
201 dThreadingImplementationID m_threading_impl;
208 m_threading_base(threading_base),
209 m_mutex_group(mutex_group),
210 m_mutex_index(mutex_index),
213 threading_base->LockMutexGroupMutex(mutex_group, mutex_index);
220 m_threading_base->UnlockMutexGroupMutex(m_mutex_group, m_mutex_index);
226 dIASSERT(m_mutex_locked);
228 m_threading_base->UnlockMutexGroupMutex(m_mutex_group, m_mutex_index);
229 m_mutex_locked =
false;
234 dIASSERT(!m_mutex_locked);
236 m_threading_base->LockMutexGroupMutex(m_mutex_group, m_mutex_index);
237 m_mutex_locked =
true;
242 dMutexGroupID m_mutex_group;
243 dmutexindex_t m_mutex_index;
247 #endif // #ifndef _ODE_THREADING_BASE_H_
Definition: threading_base.h:49
Definition: threading_base.h:204
Definition: threading_base.h:42
Definition: threading.h:154
An interface structure with function pointers to be provided by threading implementation.
Definition: threading.h:370