Search code examples
rustmio

Is it possible to register multiple timeouts in mio?


I have written a TCP server in mio and registered multiple timeouts, but only the last registered timeout fires. Do I need a wrapper for my timeouts to combine them or are there any other ways to register multiple timeouts in mio v0.5?


Solution

  • I registered a tuple with an id

    event_loop.timeout_ms((id, ServerTimeout::T1(timeout)), duration)
    

    It didn't work, so I added id to ServerTimeout::T1 and called the timeout_ms method again:

    event_loop.timeout_ms(ServerTimeout::T1(id, timeout), duration)