22 #if !defined(TASK_SCHEDULER_DEBUG) 23 #error("TASK_SCHEDULER_DEBUG is not defined") 26 #if !defined(TASK_SCHEDULER_ASSERT) 27 #error("TASK_SCHEDULER_ASSERT is not defined") 30 #if TASK_SCHEDULER_DEBUG == 0 31 #define ts_debug_only(x) 33 #define ts_debug_only(x) x 36 #if TASK_SCHEDULER_ASSERT == 0 37 #define ts_assert(x) ts_unused(x) 38 #define ts_always_assert() 40 #define ts_assert(x) assert(x) 41 #define ts_always_assert() ts_assert(0) 44 #if TASK_SCHEDULER_PROFILER == TASK_SCHEDULER_PROFILER_ITT 45 #include "ittnotify.h" 51 #define ts_join_string(arg0, arg1) ts_do_join(arg0, arg1) 52 #define ts_do_join(arg0, arg1) arg0##arg1 54 #define ts_unique_variable(basename) ts_join_string(basename, __COUNTER__) 56 #define ts_unused(x) (x)=(x); 76 template <
typename T,
typename... Args > thread_mask_int_t
create_mask_64(T first, Args... args)
92 : previous_thread_id(0)
103 int64_t new_thread_id = std::hash< std::thread::id >()(std::this_thread::get_id());
104 previous_thread_id = storage.last_thread_id.exchange(new_thread_id);
105 bool success = previous_thread_id == 0 || previous_thread_id == new_thread_id;
117 int64_t stored_thread_id = storage.last_thread_id.exchange(previous_thread_id);
118 int64_t current_thread_id = std::hash< std::thread::id >()(std::this_thread::get_id());
119 bool success = stored_thread_id == current_thread_id || stored_thread_id == 0;
128 std::atomic_int64_t previous_thread_id;
150 class_type.enter(param);
156 class_type.enter(param);
169 TClassType class_type;
189 TClassType class_type;
214 template<
class TInterface,
class TKey = TInterface>
215 inline TInterface*
get()
217 static TInterface* system =
nullptr;
220 system = TInterface::instance<TKey>();
225 template<
class TInterface,
class TAsType,
class TKey = TInterface>
226 inline TAsType* get_as()
228 static TAsType* system_as_type =
nullptr;
231 system_as_type =
static_cast<TAsType*
>(get<TInterface, TKey>());
233 return system_as_type;
236 template<
class TInterface,
class TKey>
239 return TInterface::allocate<TKey>();
242 template<
class TInterface>
243 void destroy(TInterface* _interface)
245 TInterface::deallocate(_interface);
248 template<
class TOwnerClass,
typename TType>
251 typedef void (TOwnerClass::*TSetFunc)(
typename TType);
252 typedef typename TType (TOwnerClass::*TGetFunc)();
256 attribute(TType _val, TOwnerClass* _owner =
nullptr,
typename TGetFunc _get_func =
nullptr,
typename TSetFunc _set_func =
nullptr);
258 TType &operator=(
const TType &_other_val);
268 template<
class TOwnerClass,
typename TType>
272 , get_func(_get_func)
273 , set_func(_set_func)
276 template<
class TOwnerClass,
typename TType>
279 return get_func ? (owner->*get_func)() : val;
282 template<
class TOwnerClass,
typename TType>
286 (owner->*set_func)(_other_val);
291 template<
class TOwnerClass,
typename TType>
296 template<
class TOwnerClass>
299 typedef void (TOwnerClass::*TSetFunc)(
const tchar_t*);
300 typedef const tchar_t*(TOwnerClass::*TGetFunc)();
303 attribute(
const tchar_t* _val, TOwnerClass* _owner =
nullptr,
typename TGetFunc _get_func =
nullptr,
typename TSetFunc _set_func =
nullptr);
304 operator const tchar_t*();
308 tstring *operator&();
315 template<
class TOwnerClass>
319 , get_func(_get_func)
320 , set_func(_set_func)
323 template<
class TOwnerClass>
326 return get_func ? (owner->*get_func)() : val.c_str();
329 template<
class TOwnerClass>
333 (owner->*set_func)(_other_val);
338 template<
class TOwnerClass>
343 #define ts_declare_attribute_and_callbacks(owner_type, type, name) \ 344 attribute<owner_type, type> name; \ 345 virtual void set_##name(type); \ 346 virtual type get_##name(); 348 #define ts_init_attribute_and_callbacks(owner_type, name, val) \ 349 name(val, this, &owner_type::get_##name, &owner_type::set_##name) 351 #define ts_declare_attribute(owner_type, type, name) \ 352 attribute<owner_type, type> name; 354 #define ts_init_attribute(owner_type, name, val) \ thread_unsafe_access_storage()
Initializes a new instance of the thread_unsafe_access_storage struct.
Definition: utils.h:200
unsafe_multi_threaded_access_detector()
Initializes a new instance of the unsafe_multi_threaded_access_detector class.
Definition: utils.h:91
Class stl_allocator.
Definition: allocator.h:16
Class scoped_enter_exit.
Definition: utils.h:140
Class unsafe_multi_threaded_access_detector.
Definition: utils.h:84
~scoped_enter_exit()
Finalizes an instance of the scoped_enter_exit class.
Definition: utils.h:162
scoped_enter_exit()
Initializes a new instance of the scoped_enter_exit class.
Definition: utils.h:178
bool exit(TClassType &storage)
Exits the specified storage.
Definition: utils.h:115
std::atomic_int64_t last_thread_id
The last thread identifier
Definition: utils.h:207
scoped_enter_exit(TParam &_param)
Initializes a new instance of the scoped_enter_exit class.
Definition: utils.h:147
thread_mask_int_t create_mask_64()
Creates the mask 64.
Definition: utils.h:68
Struct thread_unsafe_access_storage
Definition: utils.h:195
bool enter(TClassType &storage)
Enters the specified storage.
Definition: utils.h:101
~scoped_enter_exit()
Finalizes an instance of the scoped_enter_exit class.
Definition: utils.h:186