Skip to content

Is there some API like "select/poll/epoll_wait"? #14961

Description

@egmkang

my application is something broadcast server, pseudo code like this:

BufferedSocket:
    vector<shared_ptr<Message>> messages_;
    OnRead():
        while(shared_ptr<Message> m = read())
            //this is important
            BroadMessageToAll(m)
    OnWrite():
        Buffer buffer = CombineMessageToBuffer(messages_)
            write(buffer)

EventLoop:
    vector<shared_ptr<BufferedSocket>> sockets = epoll_wait()
    for each socket in sockets:
        if socket.readable()
            socket.OnRead()
        if socket.writable()
            socket.OnWrite()

I want gather write option, call system call "write" once to send everything(maybe twice). that is what i do in cpp.
how can i do this thing in rust?
or there is a better way?

thanks a lot.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions