Comments (7)
up-to 0x7fffffff millisec (24 days) is enough for modern operation systems. longer period can be divided into sub periods.
from asyncnet.
我的意思是。这定时器,最多只能运行正常49天,因为保存当前时间的变量是uint32_t,一直在运行的话,这个值会一直增加,如果初值为0,正好可以运行49天,如果初值不为0, 运行不到49天。而不是定时器的时长49天或int32的24天是足够了。
from asyncnet.
你没看懂,你好好看看所有判断时间的地方是怎么写的
from asyncnet.
关于时间超过uint32的范围,我只看到以下地方,有一部分处理,但处理并不完善。
if (diff > ITIMER_MGR_LIMIT + limit) {
mgr->millisec = millisec;
}
else if (diff < -ITIMER_MGR_LIMIT - limit) {
mgr->millisec = millisec;
}
from asyncnet.
具体哪行有问题呢?你还是没理解,关键处是求时间差并非直接相减,而都是itimediff函数,由于负数在计算机内是补码方式存在,-1是0xffffffff不是0x80000001。刚好范围就是循环的,itimediff(1,0xffffffff)的值为2,并非-0xfffffffe。这样的循环效果只要前后不超过0x7fffffff,有什么问题呢?tcp协议实现中sn照样是是uint32的,用的同样的循环计算法,每次链接建立时初始sn还都是随机值,照你的理解,每次tcp传文件如果内容大于或者接近4g时,链接不得断开重新来啊?
from asyncnet.
thanks . 实际测试了下。确实如此。
from asyncnet.
基础知识啊。。。。。
from asyncnet.
Related Issues (3)
- win10 编译报错 HOT 3
- 请教韦老师关于模块化的问题? HOT 3
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 asyncnet.