luminousmen / grokking_concurrency Goto Github PK
View Code? Open in Web Editor NEW"Grokking Concurrency" book code examples
License: Apache License 2.0
"Grokking Concurrency" book code examples
License: Apache License 2.0
grokking_concurrency/Chapter 8/reader_writer/reader_writer.py
Lines 41 to 43 in af926a9
In Librarian::run function, Librarian thread releases a writer lock and then immediately acquires a writer lock.
Other User threads can not acquire a writer lock in RWLock::acquire_read function. so... User threads result in starvation.
I think Librarian thread should release a writer lock before sleeping. :)
I noted a big fix 667d37e added the following snippet to method _on_accept
of class Server
:
grokking_concurrency/Chapter 11/pizza_reactor.py
Lines 83 to 84 in 667d37e
Basically, the snippet re-register server_socket
in the event loop every time a new connection is established with a client. As 667d37e said, the server cannot connect multiple clients without re-registration. In contrast, _on_read
and _on_write
handlers do not re-register sockets, but a client may send messages to the server multiple times.
What makes server_socket
different so that we must re-register it to enble multiple connections to clients?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.