1 #ifndef UVW_RESOURCE_INCLUDE_H
2 #define UVW_RESOURCE_INCLUDE_H
8 #include "underlying_type.hpp"
19 template<
typename T,
typename U>
24 auto parent()
const noexcept {
25 return this->
loop().loop.get();
28 void leak() noexcept {
29 sPtr = this->shared_from_this();
32 void reset() noexcept {
36 bool self()
const noexcept {
37 return static_cast<bool>(sPtr);
41 explicit Resource(ConstructorAccess ca, std::shared_ptr<Loop> ref)
44 std::enable_shared_from_this<T>{}
46 this->get()->data =
this;
53 template<
typename R =
void>
54 std::shared_ptr<R>
data()
const {
55 return std::static_pointer_cast<R>(userData);
62 void data(std::shared_ptr<void> uData) {
63 userData = std::move(uData);
67 std::shared_ptr<void> userData{
nullptr};
68 std::shared_ptr<void> sPtr{
nullptr};
73 #endif // UVW_RESOURCE_INCLUDE_H