考虑加入盗取门槛信息
是可以优化一些的,但是不是很多
原先的
[2023-10-23 23:58:21.626] ----> [MyTimerAspect] [] time cost is : [46252.16] ms [2023-10-23 23:59:07.309] ----> [MyTimerAspect] [] time cost is : [45680.90] ms [2023-10-23 23:59:52.901] ----> [MyTimerAspect] [] time cost is : [45590.37] ms [2023-10-24 00:00:38.379] ----> [MyTimerAspect] [] time cost is : [45477.71] ms [2023-10-24 00:01:24.546] ----> [MyTimerAspect] [] time cost is : [46165.72] ms
修改后,加入 has_task标志的
[2023-10-23 23:54:26.765] ----> [MyTimerAspect] [] time cost is : [46127.58] ms [2023-10-23 23:55:10.238] ----> [MyTimerAspect] [] time cost is : [43471.36] ms [2023-10-23 23:55:55.499] ----> [MyTimerAspect] [] time cost is : [45259.14] ms [2023-10-23 23:56:40.547] ----> [MyTimerAspect] [] time cost is : [45046.93] ms
加入细分 task 标志的
[2023-10-24 00:03:42.896] ----> [MyTimerAspect] [] time cost is : [45627.15] ms [2023-10-24 00:04:27.577] ----> [MyTimerAspect] [] time cost is : [44678.83] ms [2023-10-24 00:05:12.058] ----> [MyTimerAspect] [] time cost is : [44479.49] ms [2023-10-24 00:05:56.153] ----> [MyTimerAspect] [] time cost is : [44093.69] ms [2023-10-24 00:06:40.338] ----> [MyTimerAspect] [] time cost is : [44184.32] ms
但是这样,可能会导致个别情况下,个别队列无法盗取。因为本来数据就不是 原子的。应该抛弃这种方式了
可以考虑,thread 中,添加一个 bool变量,标记是否有内容可以偷