Comments (1)
问题1
- Lobby中eventloop的逻辑是每次循环只处理一个事件,因为eventfd使用的是信号量模式,每次read会使val减一,如果val不为零在下一轮的eventloop中会继续触发POLLIN事件,此时可处理剩余的请求。
- 此处将eventfd作为一种信号机制,避免了每次popfront之前都要判空,减少了锁使用的频率。这里也确实存在优化的空间,即采用传统的通知机制,并且在eventloop中也维护一个list,当eventfd活跃时交换两个list,这样做可以最小程度的减少锁的争用,进一步提高效率。
问题2和3
- RPC JoinRoom的接口实现于Lobby,cc Line 79,在此函数调用中,只有当房间存在空位时,才会调用Room::JoinRoom函数,因此不会产生恶性bug,但问题中的isFull函数确实是没有必要的,可进行优化。
from ua_blackjack_server.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ua_blackjack_server.