| Age | Commit message (Collapse) | Author |
|
still have some problem:
- `arg: &'a mut T ` need be `&'a mut T` or `&'a T` ?
- for RefCell::new(session), how to ensure the life cycle?
test code update
|
|
- periodic timeout, start time only supports relative time.
- first expired on now + timeout, then expired at now + timeout + timeout + ..
TimeoutManager
- add Iterator for expired_timeouts and netx_tiemouts
- expired_timeout support periodic timeout, only return quote (Ownership still on C side)
test code update
|
|
make mod be pub
|
|
|
|
|
|
Test code update
|
|
- use ref can not fix timeout's life cycle.
- rewrite is_pending / is_expired , no need `& mut self` anymore.
- fix drop for Timeout.
TimeoutSItFlag
- remove TIMEOUTS_CLEAR: make sure when call TimeoutManager::next_timeout , any list will not chang.
TimeoutManager
- add: Pass in ownership of the Timeout object
- next_expired_timeout -> expired_timeout: Ownership of timeout objects moved from c to rust
- next_timeout: return next quote of timeout objects
Test code update
|
|
|
|
- fix TimeoutSIt drop 时候 free 内存()
- TimeoutManager: get_next_wait_time 根据 c 代码,修正 定义 和 单元测试
- test_timeout_manger 单元测试
|
|
|
|
补充 TimeoutSItFlag 单元测试
|
|
- 修正 TimeoutSIt 实例申请 bug (Box::into_raw)
|
|
- timeout 申请内存在 rust 通过 Box::into_raw 将所有权交给 C 侧. 最后 Timeout drop 时 调用 C free释放
- 主要为了 is_pending is_expired 等方法减少样板代码
- 修正 NonNull 错误
- 简化 TimeoutType
- timeout_type timeout 的单元测试 通过
|
|
|
|
- 字符串常量补充 `\0`
- timeout_t 改为 rust 的 u64 类型
- 精简 timeouts 结构体声明(无需)
|
|
|
|
|
|
ffi 导出 bind 完整过了测试.
|
|
|
|
|
|
对宏定义有优化,断点追踪时常失效.
|
|
|
|
补充缺失的 struct 定义
|
|
的断点调试了.
- 一个缺点: c 代码中变量有时会识别成 rust 的可空类型, 个别时候得手动加个打印
|
|
|
|
|
|
|
|
- cfg1 测试不通过, 临时的 now 超过了 100 就 panic
- cfg2b 反而可以测试通过;
修正了 timeout.rs 的几个类型错误, 为一些结构体 提供默认初始化方法.
|
|
|
|
|
|
|
|
todo: 宏定义部分待检查.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Technically, when int is 32-bit, 1<<31 is an overflow.
|
|
|
|
nmathewson-test_foreach
|
|
|
|
nmathewson-fixing_intervals
|
|
only using POSIX make syntax and semantics
|
|
|
|
|
|
Also, make them check the required invariants for to->expires after
timeout_readd().
Also, actually use the different timeout values in the main()
function (whoops).
|
|
William Ahern tells me that the intent here is that timeout_readd()
should always reschedule the timeout at the first time in the future
that is an even multiple of to->interval, as if we had called:
do {
to->expires += to->interval;
} while (to->expires <= T->curtime);
But of course, that's not efficient. The implementation strategy
used in this patch simplifies the calculation down to a single %
operation, plus a few additions and subtractions.
To verify the correctness of the formula used here, note first that
0 <= r < to->interval, and so
0 < to->interval - r <= to->interval. Since
expires' = curtime + (interval - r),
curtime < expires' <= curtime + interval,
and so the new expiration time is no more than one interval after
curtime.
Note second that since
r = (curtime - expires) % interval,
expires' = curtime + (interval - r), we have
(expires' - expires) % interval =
(curtime + (interval - r) - expires) % interval =
(curtime - r - expires) % interval =
(curtime - (curtime-expires) % interval - expires) % interval =
(curtime - curtime + expires - expires) % interval =
0.
And so the new expiration time is an even multiple of interval from
the original expiration time.
Since we have both properties we wanted, this formula should be right.
|
|
|