In this presentation we revisit the HTTP Web Server by looking at other system call apis that allow us to perform non-blocking calls. We look at various event based / queue based apis such as epoll, kqueue, poll, iocp, io_uring, wepoll. To build for these apis I cover the implementation of a State Machine and its use in working with a client request over time. We learn about the Reactor Pattern, Event Loops, executing tasks, polling event handlers, boxed dynamic traits, sending and sharing with send/sync, using a read/write lock and working with static lifetimes along the way. By the end of our presentation we will have successfully built a fully concurrent state machine that works with non-blocking I/O apis, executing tasks within an event loop, and using the reactor pattern to schedule and switch between various states in the client request. While this solution doesn't explicitly implement async/.await we cover the importance of understanding and implementing it this way and how the Rust compiler will actually generate something very similar to it.
In building the state machine by hand, we now are ready to move into building our own Async Runtime and working with Futures. We have a good understanding of the event loop, the reactor pattern, executing and scheduling tasks concurrently, and handling non-blocking I/O with various non-blocking event/queue based underlying system apis. We will take advantage of this in the next video in this series by building our own async runtime.
↠ References:
Reactor Pattern: [ Ссылка ]
epoll: [ Ссылка ]
epoll/kqueue/iocp: [ Ссылка ]
poll: [ Ссылка ]
as_raw_fd: [ Ссылка ]
Poller: [ Ссылка ]
RwLock: [ Ссылка ]
Arc: [ Ссылка ]
Mutex: [ Ссылка ]
Box: [ Ссылка ]
dyn Trait keyword: [ Ссылка ]
std::process: [ Ссылка ]
fs::File: [ Ссылка ]
BufWriter: [ Ссылка ]
BufReader: [ Ссылка ]
HTTP Protocol: [ Ссылка ]
Radix Tree: [ Ссылка ]
Interrupts: [ Ссылка ]
Virtual Memory: [ Ссылка ]
JoinHandle: [ Ссылка ]
thread::spawn: [ Ссылка ]
std::net::TcpListener: [ Ссылка ]
std::net::SocketAddr: [ Ссылка ]
std::net::TcpStream: [ Ссылка ]
std::io::Stdin: [ Ссылка ]
std::io::Stdout: [ Ссылка ]
socket: [ Ссылка ]
setsocketopt: [ Ссылка ]
bind: [ Ссылка ]
listen: [ Ссылка ]
connect: [ Ссылка ]
write: [ Ссылка ]
read: [ Ссылка ]
libc crate: [ Ссылка ]
↠ Dotfiles: [ Ссылка ]
↠ Twitter: @nyxtom [ Ссылка ]
↠ Channel: [ Ссылка ]
Cheers! 🍻
🦀 #rust #rustlang #rustprogramming #exercises #programming
Ещё видео!