oathdruid commented on issue #2762: URL: https://github.com/apache/brpc/issues/2762#issuecomment-2364986602
目前消费动作应该也是用这个exchage摘除队尾的方式来做的。正向链消费感觉会有一些比较困难的点 1、需要再留一个虚拟头,消费从虚拟头发起,也给队尾侧提供一个起点 2、从虚拟头消费时候,不好确定终止点,遇到nullptr有可能是真的尾,也可能是正在准备链接的中间,需要读取当前尾部进行校验 3、要做按需启动消费的话,不能单纯像现在依赖交换结果来判断,需要加一些额外的计数机制联合使用 4、不过最麻烦的还是,正向接链表会导致,最后一个节点消费后,很难直接找到安全delete/recycle掉的时机(因为随时有可能有新的入队需要操作它的next, 逆向是不会有这种问题的);那么就需要用虚拟头来交换尾节点,然后这个交换又可能交换到更新的插入者,还要再一次尝试跟随nullptr直到这个自己交换得到的尾部; 初步这么理了下,感觉好像不是不能做,不过实现复杂度提升不少 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org