Git Product home page Git Product logo

Comments (1)

Thomasdezeeuw avatar Thomasdezeeuw commented on September 28, 2024 1

Some time ago I remember seeing a notice along the lines of "Streams registered to a Poll on one thread can only be read on the same thread," or "Streams which Events were received on one thread must be read on the same thread." I don't remember the exact wording or the version of mio, but I can't find such a line in current docs. Does that mean that it is now possible to create connections, register for events, poll events and read streams on different threads?

I don't know where you saw this, but both statements are inaccurate.

For example: Thread 1: creates a TcpStream Thread 2: creates a Poll, registers and and polls events Thread 3: reads from and writes to the TcpStream after a readiness event is received.

Would that configuration work or am I missing something?

TcpStream, like all other types exposed by Mio, are usable from any thread. Some methods need mutable, e.g. Poll::poll, but then we use &mut self instead of &self. If the type is Send and the method takes an immutable reference (i.e. &self) it's safe to use across threads.

Btw the above goes for any Rust code, otherwise it would be unsound.

from mio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.