[SERVER-71731] Replace Duration with std::chrono::duration Created: 01/Dec/22 Updated: 03/May/23 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Billy Donahue | Assignee: | Backlog - Service Architecture |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Assigned Teams: |
Service Arch
|
||||||||||||
| Participants: | |||||||||||||
| Description |
|
This would enable us to mostly remove our Duration and simply focus on the operations of the arithmetic type with the overflow canarying we want to use for its Rep. Special integer value to represent infinity. Detect and absorb overflow on arithmetic operations. Gain access to stdlib-quality implementations of time-related functions and operators. Retain mongo names for the Duration types. Eliminate friction between stdlib APIs and our code. Captured from Slack discussion about C++20 support (PM-3140). I like Howard Hinnant's idea of using a custom numeric type and otherwise making our duration types aliases to some std::chrono::duration<SafeRep,Period> directly. I've considered the same solution, but thought it wasn't allowed because of this misleading cppreference language: "rep: an arithmetic type representing the number of ticks" Which would disqualify custom numeric types. What the standard actually has said since C++11 is: "rep: An arithmetic type or a class emulating an arithmetic type" And the requirements on that type are spelled out.
( |