yum-mirror/VkFFT

git clone https://git.yummers.dev/yum-mirror/VkFFT

Tolmachev DmitriiMetal support in VkFFTba7001c

master
3.7 KiB105 linesraw
1//-------------------------------------------------------------------------------------------------------------------------------------------------------------
2//
3// Foundation/NSLock.hpp
4//
5// See LICENSE.txt for this project licensing information.
6//
7//-------------------------------------------------------------------------------------------------------------------------------------------------------------
8
9#pragma once
10
11//-------------------------------------------------------------------------------------------------------------------------------------------------------------
12
13#include "NSDefines.hpp"
14#include "NSObject.hpp"
15#include "NSPrivate.hpp"
16#include "NSTypes.hpp"
17#include "NSDate.hpp"
18
19//-------------------------------------------------------------------------------------------------------------------------------------------------------------
20
21namespace NS
22{
23
24template <class _Class, class _Base = class Object>
25class Locking : public _Base
26{
27public:
28    void lock();
29    void unlock();
30};
31
32class Condition : public Locking<Condition>
33{
34public:
35    static Condition* alloc();
36
37    Condition*        init();
38
39    void              wait();
40    bool              waitUntilDate(Date* pLimit);
41    void              signal();
42    void              broadcast();
43};
44
45} // NS
46
47//-------------------------------------------------------------------------------------------------------------------------------------------------------------
48
49template<class _Class, class _Base /* = NS::Object */>
50_NS_INLINE void NS::Locking<_Class, _Base>::lock()
51{
52    NS::Object::sendMessage<void>(this, _NS_PRIVATE_SEL(lock));
53}
54
55//-------------------------------------------------------------------------------------------------------------------------------------------------------------
56
57template<class _Class, class _Base /* = NS::Object */>
58_NS_INLINE void NS::Locking<_Class, _Base>::unlock()
59{
60    NS::Object::sendMessage<void>(this, _NS_PRIVATE_SEL(unlock));
61}
62
63//-------------------------------------------------------------------------------------------------------------------------------------------------------------
64
65_NS_INLINE NS::Condition* NS::Condition::alloc()
66{
67    return NS::Object::alloc<NS::Condition>(_NS_PRIVATE_CLS(NSCondition));
68}
69
70//-------------------------------------------------------------------------------------------------------------------------------------------------------------
71
72_NS_INLINE NS::Condition* NS::Condition::init()
73{
74    return NS::Object::init<NS::Condition>();
75}
76
77//-------------------------------------------------------------------------------------------------------------------------------------------------------------
78
79_NS_INLINE void NS::Condition::wait()
80{
81    NS::Object::sendMessage<void>(this, _NS_PRIVATE_SEL(wait));
82}
83
84//-------------------------------------------------------------------------------------------------------------------------------------------------------------
85
86_NS_INLINE bool NS::Condition::waitUntilDate(NS::Date* pLimit)
87{
88    return NS::Object::sendMessage<bool>(this, _NS_PRIVATE_SEL(waitUntilDate_), pLimit);
89}
90
91//-------------------------------------------------------------------------------------------------------------------------------------------------------------
92
93_NS_INLINE void NS::Condition::signal()
94{
95    NS::Object::sendMessage<void>(this, _NS_PRIVATE_SEL(signal));
96}
97
98//-------------------------------------------------------------------------------------------------------------------------------------------------------------
99
100_NS_INLINE void NS::Condition::broadcast()
101{
102    NS::Object::sendMessage<void>(this, _NS_PRIVATE_SEL(broadcast));
103}
104
105//-------------------------------------------------------------------------------------------------------------------------------------------------------------