The limitations of using IO operations on files

As mentioned, some libraries, such as SQLite, use blocking operations to perform queries to a database and get the result back, but this depends on what kind of IO they use. A network stack is completely asynchronous in modern operating systems, but the input/output of files is harder to use asynchronously. Operating systems contain functions to carry out asynchronous reading or writing, but it's hard to implement this with cross-platform compatibility. It's simpler to use a separate thread to handle hard-drive IO interactions. The tokio crate uses a separate thread to handle the IO of files. Other platforms, such as Go or Erlang, do the same thing. You can use asynchronous IO for files for specific operating systems, but this isn't a very flexible approach.

Now that you know the difference between synchronous and asynchronous tasks, we're ready to create an asynchronous service that uses a separate thread for the CPU-bound task of resizing images.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.55.193