Skip to content

Commit 0b2eed0

Browse files
committed
Correct logic of new ISyncObject::FindWeightHigherThan().
1 parent e4c8cac commit 0b2eed0

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

stk/include/stk_helper.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,20 +246,17 @@ inline bool ISyncObject::Tick(Timeout elapsed_ticks)
246246
//! Implementation of ISyncObject::Tick, see \a ISyncObject. Placed here as it depends on \a GetUserTaskFromTid.
247247
inline Weight ISyncObject::FindWeightHigherThan(Weight comp) const
248248
{
249-
Weight result = NO_WEIGHT;
249+
Weight max_weight = NO_WEIGHT;
250250

251251
for (const IWaitObject *itr = static_cast<IWaitObject *>(m_wait_list.GetFirst()); (itr != nullptr);
252252
itr = static_cast<IWaitObject *>(itr->GetNext()))
253253
{
254254
Weight w = GetUserTaskFromTid(itr->GetTid())->GetWeight();
255-
if (w > comp)
256-
{
257-
result = w;
258-
break;
259-
}
255+
if (w > max_weight)
256+
max_weight = w;
260257
}
261258

262-
return result;
259+
return ((max_weight > comp) ? max_weight : NO_WEIGHT);
263260
}
264261

265262
//! Implementation of ITask::GetId, see \a ITask. Placed here as it depends on \a GetTidFromUserTask.

0 commit comments

Comments
 (0)