1#ifndef UVW_RESOURCE_INCLUDE_H
2#define UVW_RESOURCE_INCLUDE_H
17template<
typename T,
typename U,
typename... E>
20 int leak_if(
int err)
noexcept {
22 self_ptr = this->shared_from_this();
28 void self_reset()
noexcept {
32 bool has_self()
const noexcept {
33 return static_cast<bool>(self_ptr);
37 explicit resource(loop::token token, std::shared_ptr<loop> ref)
39 this->
raw()->data =
this;
46 template<
typename R =
void>
47 std::shared_ptr<R>
data()
const {
48 return std::static_pointer_cast<R>(user_data);
55 void data(std::shared_ptr<void> udata) {
56 user_data = std::move(udata);
60 std::shared_ptr<void> user_data{
nullptr};
61 std::shared_ptr<void> self_ptr{
nullptr};
Event emitter base class.
Common class for almost all the resources available in uvw.
void data(std::shared_ptr< void > udata)
Sets arbitrary data. uvw won't use this field in any case.
std::shared_ptr< R > data() const
Gets user-defined data. uvw won't use this field in any case.
Wrapper class for underlying types.
const U * raw() const noexcept
Gets the underlying raw data structure.