Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fromRaw function to loop #157

Closed
wants to merge 1 commit into from
Closed

Add fromRaw function to loop #157

wants to merge 1 commit into from

Conversation

tversteeg
Copy link
Contributor

I needed to add this function to be able to use a luv loop in my code.

auto loop = uvw::Loop::fromRaw(luv_loop(...));
loop->run<uvw::Loop::Mode::NOWAIT>();

@skypjack
Copy link
Owner

Wouldn't it be better something like this?

    static std::shared_ptr<Loop> create(uv_loop_t *ext) {
        auto ptr = std::unique_ptr<uv_loop_t, Deleter>{ext, [](uv_loop_t *){}};
        return std::shared_ptr<Loop>{new Loop{std::move(ptr)}};
    }

@skypjack skypjack self-assigned this Aug 27, 2019
@tversteeg
Copy link
Contributor Author

I was considering this as well, but seeing that using the create() constructor would be the default recommended way and you wanting to discourage people to use raw C pointers I thought it would be better to create a different constructor for it.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 97.624% when pulling 8f9aed9 on tversteeg:master into ea4b6c8 on skypjack:master.

@skypjack skypjack closed this in 3264417 Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants