diff --git a/UsbDk/UsbDkUtil.h b/UsbDk/UsbDkUtil.h index 19090c6..02d6b01 100644 --- a/UsbDk/UsbDkUtil.h +++ b/UsbDk/UsbDkUtil.h @@ -123,39 +123,40 @@ public: } template - void ForEachDetached(TFunctor Functor) + bool ForEachDetached(TFunctor Functor) { CLockedContext LockedContext(*this); while (!IsListEmpty(&m_List)) { if (!Functor(Pop_LockLess())) { - return; + return false; } } + return true; } template - void ForEachDetachedIf(TPredicate Predicate, TFunctor Functor) + bool ForEachDetachedIf(TPredicate Predicate, TFunctor Functor) { - ForEachPrepareIf(Predicate, [](PLIST_ENTRY Entry){ RemoveEntryList(Entry); }, Functor); + return ForEachPrepareIf(Predicate, [](PLIST_ENTRY Entry){ RemoveEntryList(Entry); }, Functor); } template - void ForEach(TFunctor Functor) + bool ForEach(TFunctor Functor) { - ForEachPrepareIf([](TEntryType*) { return true; }, [](PLIST_ENTRY){}, Functor); + return ForEachPrepareIf([](TEntryType*) { return true; }, [](PLIST_ENTRY){}, Functor); } template - void ForEachIf(TPredicate Predicate, TFunctor Functor) + bool ForEachIf(TPredicate Predicate, TFunctor Functor) { - ForEachPrepareIf(Predicate, [](PLIST_ENTRY){}, Functor); + return ForEachPrepareIf(Predicate, [](PLIST_ENTRY){}, Functor); } private: template - void ForEachPrepareIf(TPredicate Predicate, TPrepareFunctor Prepare, TFunctor Functor) + bool ForEachPrepareIf(TPredicate Predicate, TPrepareFunctor Prepare, TFunctor Functor) { CLockedContext LockedContext(*this); @@ -171,10 +172,12 @@ private: Prepare(CurrEntry); if (!Functor(Object)) { - return; + return false; } } } + + return true; } TEntryType *Pop_LockLess()