Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    RUSshy
    @RUSshy
    i feel like i missed one step but i don't see what, i'm not familiar with cmake
    RUSshy
    @RUSshy
    ohh nvm, i put it in the wrong folder
    hmm next thing i don't get is i consume already libuv as a static library, and when using uvw it complains about not finding libuv.dll
    Michele Caini
    @skypjack
    If you use uvw as header only, it doesn't include and link libuv for you
    That's why the linker complains :)
    RUSshy
    @RUSshy
    i did that already: target_link_libraries(${PROJECT_NAME} PRIVATE opengl32 glad glfw arc cmn ws2_32 uv)
    oh i think i got it uv => uv_a :trollface:
    ok that was that, it works fine now!
    Michele Caini
    @skypjack
    :+1:
    DuckVador
    @DuckVador
    图片.png
    this test cause double free, when call h->type(). I'm wondering what is the reason.
    Michele Caini
    @skypjack
    is it one of the tests from uvw or one you wrote?
    DuckVador
    @DuckVador
    my own test
    Michele Caini
    @skypjack
    ok, did you try with an interval that is larger than 0ms?
    DuckVador
    @DuckVador
    still double free
    actually, if I call h->active, seems everything is ok.
    I pasted my code here :https://pastebin.com/raw/3xeJHfmp
    Commander Keen
    @madhat1
    Hello people, I'm wondering where I can find real world samples of using UVW.
    Official documentation shows an example of a TCP server, I'm looking for Timer and File I/O examples.
    Michele Caini
    @skypjack
    GitHub contains many example if you like
    Commander Keen
    @madhat1
    I couldn't find timer and file I/O examples, can you direct me to them?
    smalls12
    @smalls12
    I can't figure out how to create a PollHandle for polling a socket to indicate when something is ready to be read
    I don't see any examples, and the tests only test FsPollHandle
    Michele Caini
    @skypjack
    @smalls12 uvw doesn't add up on libuv, if you know how to do that with the latter, you can just translate it to the former
    PollHandle offers start and stop as expected and they work exactly as their counterparts in libuv
    smalls12
    @smalls12
    I should provide more context
    I am trying to integrate a 3rdparty library with libuv / uvw similar to how I would use boost::asio
    basically I just want the libuv event loop to tell me when there is something to read or write and hand that off to the 3rdparty library
    Michele Caini
    @skypjack
    This doesn't really add much :slight_smile: the documentation for a poll handle in libuv is here, with uvw it's just a matter of invoking a member function rather than a free function
    You pass a file descriptor to the constructor and invoke start, that's it
    Events are sent when something relevant happens, you can listen to them with a callback
    All this stuff is described in the readme file though and it's literally the same for all classes
    How you obtain a file descriptor doesn't depende on libuv nor uvw, so it's up to you
    smalls12
    @smalls12
    I'll post the code I have tried when I get back infront of it
    smalls12
    @smalls12
    I'm back looking at this now
    this is the code I have tried, it is seg faulting on me
    auto loop = uvw::Loop::getDefault();
    
        auto poller = loop->resource<uvw::PollHandle>(fd);
        poller->on<uvw::PollEvent>(
        [](const auto &, auto &req)
        {
            std::cout << "poller - some event?\n";
        });
    
        if(poller->init())
        {
            std::cout << "poller - initialized?\n";
            poller->start(uvw::PollHandle::Event::READABLE);
        }
        else
        {
            std::cerr << "poller - error?\n";
        }
    
        loop->run();
    is this what you expected?
    fd is the file descriptor from the other library
    Michele Caini
    @skypjack
    No, it's not expected but it's hard to tell what the problem is without a reproducible example. From what I can see, it can be in uvw, it can be in the other library, it can be elsewhere in the middle...
    smalls12
    @smalls12
    ok the fd was actually -1
    doh
    now it is working
    but I do not see any events indicating something is available to read
    smalls12
    @smalls12
    ok that was my problem again
    I think I did something wrong with the ::on call
    the event is being spammed now with some poll event
    instead of only indicating when there is data to read
    smalls12
    @smalls12

    trying to get some more information from the event

    poller->on<uvw::PollEvent>(
        [](const uvw::PollEvent& event, uvw::PollHandle& handle)
        {
    
        });

    is there anything to be obtained from event or handle?

    Michele Caini
    @skypjack
    You can look at the documentation of either uvw or libuv, because the event wraps the underlying event (if any) and the handle does the same with a libuv's poll handle
    That is, uvw is a layer on top of libuv and makes you available what is exposed by the underlying library
    smalls12
    @smalls12
    I was able to solve it.
    Would you accept a PR showing how to use the poller? Since it is not explicitly captured in an example?
    Michele Caini
    @skypjack
    Sure thing, PRs are always welcome :slight_smile: