-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blockDeque的一些疑问 #118
Comments
1..这个项目没有使用双端队列,但给出了诸如pop_back pop_front等函数 |
关于log还有一个点没明白,写线程FlushLogThread中锁的逻辑应该是这样的?while判断条件中进入pop,pop会先获取锁,如果队列为空则释放锁进入休眠,然后while条件满足了,就获取锁保护fp,进行fputs操作,写完之后又释放。那就有个问题,如果write中需要切换文件,然后又在图三中第一句等待锁的释放,那写线程(图二)尚未写完当前log队列的数据,那锁被write获取了,进行切换为文件的操作,这会不会导致旧数据写入新文件。还是说我对锁的理解错了 |
1.双端队列哪里有体现吗,异步写log不应该得按照日志数据的顺序来的吗?
2.为什么pop跟push函数中,pop的while要判断队列是否关闭从而返回false,但是push中却没有这个判断呢。我的理解是既然是异步了,就得做好丢失数据的可能(小白不知道有没有什么其他办法可以解决),那push也应该判断是否关闭了,不然是不是我日志系统关闭后还能继续push但是不能pop了,那不是没意义了(写入缓冲区但是没有写到文件中)
The text was updated successfully, but these errors were encountered: