mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2026-10-02 15:53:20 -05:00
Implementation of new StorageAPI
This commit is contained in:
@@ -63,18 +63,40 @@ std::shared_ptr<T> make_shared_nothrow(Args &&...args) noexcept(noexcept(T(std::
|
||||
}
|
||||
|
||||
template<typename Container, typename Predicate>
|
||||
bool remove_locked_first_if(std::mutex &mutex, Container &container, Predicate pred) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
typename std::enable_if<std::is_same<Container, std::forward_list<typename Container::value_type>>::value, bool>::type
|
||||
remove_first_if(Container &container, Predicate pred) {
|
||||
auto it = container.before_begin();
|
||||
|
||||
auto it = std::find_if(container.begin(), container.end(), pred);
|
||||
if (it != container.end()) {
|
||||
container.erase(it);
|
||||
return true;
|
||||
for (auto prev = it, current = ++it; current != container.end(); ++prev, ++current) {
|
||||
if (pred(*current)) {
|
||||
container.erase_after(prev);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Container, typename Predicate>
|
||||
typename std::enable_if<std::is_same<Container, std::set<typename Container::value_type>>::value, bool>::type
|
||||
remove_first_if(Container &container, Predicate pred) {
|
||||
auto it = container.begin();
|
||||
while (it != container.end()) {
|
||||
if (pred(*it)) {
|
||||
container.erase(it);
|
||||
return true;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<typename Container, typename Predicate>
|
||||
bool remove_locked_first_if(std::mutex &mutex, Container &container, Predicate pred) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
return remove_first_if(container, pred);
|
||||
}
|
||||
|
||||
std::string getPluginPath();
|
||||
|
||||
OSDynLoad_Error CustomDynLoadAlloc(int32_t size, int32_t align, void **outAddr);
|
||||
|
||||
Reference in New Issue
Block a user