@@ -67,8 +67,9 @@ EventImplPtr Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
67
67
const bool IsKernel = CommandGroup->getType () == CG::KERNEL;
68
68
{
69
69
std::unique_lock<std::shared_timed_mutex> Lock (MGraphLock, std::defer_lock);
70
- while (!Lock.try_lock ())
71
- ;
70
+ while (!Lock.owns_lock ()) {
71
+ Lock.try_lock ();
72
+ }
72
73
73
74
switch (CommandGroup->getType ()) {
74
75
case CG::UPDATE_HOST:
@@ -94,8 +95,9 @@ EventImplPtr Scheduler::addCG(std::unique_ptr<detail::CG> CommandGroup,
94
95
95
96
EventImplPtr Scheduler::addCopyBack (Requirement *Req) {
96
97
std::unique_lock<std::shared_timed_mutex> Lock (MGraphLock, std::defer_lock);
97
- while (!Lock.try_lock ())
98
- ;
98
+ while (!Lock.owns_lock ()) {
99
+ Lock.try_lock ();
100
+ }
99
101
Command *NewCmd = MGraphBuilder.addCopyBack (Req);
100
102
// Command was not creted because there were no operations with
101
103
// buffer.
@@ -152,8 +154,9 @@ void Scheduler::cleanupFinishedCommands(EventImplPtr FinishedEvent) {
152
154
153
155
void Scheduler::removeMemoryObject (detail::SYCLMemObjI *MemObj) {
154
156
std::unique_lock<std::shared_timed_mutex> Lock (MGraphLock, std::defer_lock);
155
- while (!Lock.try_lock ())
156
- ;
157
+ while (!Lock.owns_lock ()) {
158
+ Lock.try_lock ();
159
+ }
157
160
158
161
MemObjRecord *Record = MGraphBuilder.getMemObjRecord (MemObj);
159
162
if (!Record)
@@ -168,12 +171,13 @@ void Scheduler::removeMemoryObject(detail::SYCLMemObjI *MemObj) {
168
171
EventImplPtr Scheduler::addHostAccessor (Requirement *Req,
169
172
const bool destructor) {
170
173
// Avoiding deadlock situation for MSVC. std::shared_timed_mutex specification
171
- // does not specify a priority for shared and exclusive locks . It will be a
174
+ // does not specify a priority for shared and exclusive accesses . It will be a
172
175
// deadlock in MSVC's std::shared_timed_mutex implementation, if exclusive
173
- // lock occurs after shared lock .
176
+ // access occurs after shared access .
174
177
std::unique_lock<std::shared_timed_mutex> Lock (MGraphLock, std::defer_lock);
175
- while (!Lock.try_lock ())
176
- ;
178
+ while (!Lock.owns_lock ()) {
179
+ Lock.try_lock ();
180
+ }
177
181
178
182
Command *NewCmd = MGraphBuilder.addHostAccessor (Req, destructor);
179
183
@@ -187,8 +191,8 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req,
187
191
}
188
192
189
193
void Scheduler::releaseHostAccessor (Requirement *Req) {
190
- Req->MBlockedCmd ->MEnqueueStatus = EnqueueResultT::SyclEnqueueReady;
191
194
std::shared_lock<std::shared_timed_mutex> Lock (MGraphLock);
195
+ Req->MBlockedCmd ->MEnqueueStatus = EnqueueResultT::SyclEnqueueReady;
192
196
MemObjRecord *Record = Req->MSYCLMemObj ->MRecord .get ();
193
197
auto EnqueueLeaves = [](CircularBuffer<Command *> &Leaves) {
194
198
for (Command *Cmd : Leaves) {
0 commit comments