Function resource

Synopsis

#include <src/uvw/loop.h>

template <typename R, typename... Args>
std::shared_ptr< R > resource(Args &&... args)

Description

Creates resources of any type.

This should be used as a default method to create resources.
The arguments are the ones required for the specific resource.

Use it as loop->resource<uvw::TimerHandle>().

Returns
A pointer to the newly created resource.

Mentioned in

Source

Lines 228-237 in src/uvw/loop.h.

template<typename R, typename... Args>
std::shared_ptr<R> resource(Args&&... args) {
    if constexpr(std::is_base_of_v<BaseHandle, R>) {
        auto ptr = R::create(shared_from_this(), std::forward<Args>(args)...);
        ptr = ptr->init() ? ptr : nullptr;
        return ptr;
    } else {
        return R::create(shared_from_this(), std::forward<Args>(args)...);
    }
}





Add Discussion as Guest

Log in