Skip to content

[CDRIVER-6048] Add New Time and Duration Functionality #2074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 70 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
524ca34
New `duration` type
vector-of-bool Apr 14, 2025
e8a607b
Add a shim header for including Win32 APIs
vector-of-bool Apr 15, 2025
4f66d77
New time point and sleeping functions
vector-of-bool Apr 15, 2025
a69e197
[fixup] Fix preproc error in #error directive
vector-of-bool Apr 16, 2025
381aba5
Convert all sleeps to use duration-typed sleeps
vector-of-bool Apr 16, 2025
9fbc463
Support infix syntax for duration comparisons
vector-of-bool Apr 16, 2025
d403401
Infix syntax for time comparison
vector-of-bool Apr 16, 2025
8641196
Fix detection of POSIX clocks on libmuslc
vector-of-bool Apr 18, 2025
33c73e9
[fixup] Header ordering for Win32
vector-of-bool Apr 18, 2025
6b68bcb
More integer comparison assertions
vector-of-bool Apr 18, 2025
d08ebe2
A deadline timer type
vector-of-bool Apr 18, 2025
eb4482d
More doc and copyright comments
vector-of-bool Apr 18, 2025
3f4d645
Use Win32 QueryPerformanceCounter for getting times
vector-of-bool Apr 18, 2025
fda1736
Change windows-lean for a general platform header
vector-of-bool Apr 21, 2025
edd30fc
Set an appropriate Windows version
vector-of-bool Apr 21, 2025
e7f39f8
[fixup] macos compat
vector-of-bool Apr 21, 2025
aa23a28
Make duration API significantly more concise.
vector-of-bool Jul 10, 2025
feb4836
Clean up some macro magic
vector-of-bool Jul 11, 2025
1b38434
Merge branch 'master' into CDRIVER-6048-time-types
vector-of-bool Jul 11, 2025
d5704de
Fix up macro expansion to support nested expressions
vector-of-bool Jul 11, 2025
af1e828
More duration for mlib_later
vector-of-bool Jul 11, 2025
c44fdfa
Fix MSVC preproc disagreements
vector-of-bool Jul 11, 2025
a953be2
Formatting
vector-of-bool Jul 11, 2025
f5501a4
Clean up macro definitions
vector-of-bool Jul 14, 2025
7dbccb6
Use mlib_now() in bson monotonic time
vector-of-bool Jul 14, 2025
864b352
More time convenience APIs
vector-of-bool Jul 23, 2025
4865813
Cleanup
vector-of-bool Jul 23, 2025
38fc430
Refactor of async command to use new time APIs
vector-of-bool Jul 23, 2025
f72cd5a
Rename a lot of private command object attributes
vector-of-bool Jul 23, 2025
bde8406
Rename accidental duplicate test case
vector-of-bool Jul 23, 2025
a23c8eb
[fixup] Missing updates in conditional sections
vector-of-bool Jul 23, 2025
5c76085
[fixup] Time member rename in Windows
vector-of-bool Jul 23, 2025
b7628ec
[fixup] More conditional compilation misses
vector-of-bool Jul 23, 2025
55ed326
Fix dead-write warning and simplify some macro usage
vector-of-bool Jul 23, 2025
c40bffc
Fix: Wrong state when setting cancellation
vector-of-bool Jul 23, 2025
af308c8
Merge branch 'master' into CDRIVER-6048-time-types
vector-of-bool Jul 23, 2025
c623b52
Fix: sleep_for not using the checked useconds value
vector-of-bool Jul 24, 2025
3e7bb31
Test case cleanup
vector-of-bool Jul 24, 2025
161c403
Comment cleanup and spelling in async-cmd
vector-of-bool Jul 24, 2025
52e9a14
Remove unneeded inclusions following a goofy merge
vector-of-bool Jul 24, 2025
4eba25c
Drop more unneeded headers
vector-of-bool Jul 24, 2025
b6aea1e
Fix copyright statements
vector-of-bool Jul 30, 2025
41c978e
const correctness
vector-of-bool Jul 30, 2025
36a1cda
Missing headers for sleep()
vector-of-bool Jul 30, 2025
d362230
Rewrite some test macros as duration types
vector-of-bool Jul 30, 2025
3e29b8f
Tweak spelling of seconds suffix, add hour suffix
vector-of-bool Jul 30, 2025
07c2568
Drive-by timer change
vector-of-bool Jul 30, 2025
1232d46
Add a function to get the cock ID for mlib_now()
vector-of-bool Jul 31, 2025
9f3b192
Tweaks following PR reviews
vector-of-bool Aug 6, 2025
6aa01b7
`MLIB_DEFERRED` macro for simpler macro magic
vector-of-bool Aug 6, 2025
d7031fe
Rewrtie client_pool_pop() to use our timer type
vector-of-bool Aug 6, 2025
0e4718a
Remove <features.h> inclusion
vector-of-bool Aug 6, 2025
a7336f4
Make cancellation requests conditional on non-error states
vector-of-bool Aug 7, 2025
190086a
Minor spelling and name changes
vector-of-bool Aug 8, 2025
43e349d
Change topology scanner to use typed times
vector-of-bool Aug 8, 2025
856e088
Revert changes for new preproc config macros
vector-of-bool Aug 14, 2025
d405460
Several more non-null checks
vector-of-bool Aug 14, 2025
5756b86
Merge branch 'master' into CDRIVER-6048-time-types
vector-of-bool Aug 14, 2025
590d51e
MInor update to use a timer
vector-of-bool Aug 14, 2025
9b56720
Header cleanup in topology-scanner.c
vector-of-bool Aug 14, 2025
170b14f
Fix header position
vector-of-bool Aug 14, 2025
f9c872e
Workaround broken MSVC preproc
vector-of-bool Aug 14, 2025
e4b3ee6
Guard against an existing definition
vector-of-bool Aug 14, 2025
bf410f5
Address implicit narrowing
vector-of-bool Aug 14, 2025
794a84e
Address conversion in division warning
vector-of-bool Aug 14, 2025
20e1a6b
Minor formatting
vector-of-bool Aug 14, 2025
93416b4
Simpler multiply overflow handling
vector-of-bool Aug 15, 2025
e0ce0c9
Add NOMINMAX globally to all sources
vector-of-bool Aug 15, 2025
0b0f2b4
Merge branch 'master' into CDRIVER-6048-time-types
vector-of-bool Aug 15, 2025
cf2ddaf
Undo NOMINMAX, just disable it locally, since NOMINMAX doesn't work on C
vector-of-bool Aug 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 34 additions & 5 deletions src/common/src/mlib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,35 @@
MLIB_JUST(_mlibPickSixteenth \
MLIB_NOTHING("MSVC workaround") \
(__VA_ARGS__, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, ~))
// Expands to a single comma if invoked as a function-like macro
#define _mlibCommaIfParens(...) ,

/**
* @brief Expands to `1` if the given macro argument is a parenthesized group of
* tokens, otherwise `0`
*/
#define MLIB_IS_PARENTHESIZED(X) \
_mlibHasComma(_mlibCommaIfParens X)

/**
* @brief Pass a function-like macro name, inhibiting its expansion until the
* next pass:
*
* #define func_macro(x) x
*
* MLIB_DEFERRED(func_macro)(foo) // Expands to "func_macro(foo)", not "foo"
*/
#define MLIB_DEFERRED(MacroName) \
/* Expand to the macro name: */ \
MacroName \
/*-
* Place a separator between the function macro name and whatever comes next
* in the file. Presumably, the next token will be the parens to invoke "MacroName",
* but this separator inhibits its expansion unless something else comes
* along to do another expansion pass
*/ \
MLIB_NOTHING("[separator]")

/**
* A helper for isEmpty(): If given (0, 0, 0, 1), expands as:
* - first: _mlibHasComma(_mlibIsEmptyCase_0001)
Expand Down Expand Up @@ -130,9 +157,8 @@
* is not expanded and is discarded.
*/
#define MLIB_IF_ELSE(...) MLIB_PASTE (_mlibIfElseBranch_, MLIB_BOOLEAN (__VA_ARGS__))
#define _mlibIfElseBranch_1(...) __VA_ARGS__ _mlibNoExpandNothing
#define _mlibIfElseBranch_0(...) MLIB_NOTHING (#__VA_ARGS__) MLIB_JUST
#define _mlibNoExpandNothing(...) MLIB_NOTHING (#__VA_ARGS__)
#define _mlibIfElseBranch_1(...) __VA_ARGS__ MLIB_NOTHING
#define _mlibIfElseBranch_0(...) MLIB_JUST

/**
* @brief Expands to an integer literal corresponding to the number of macro
Expand All @@ -146,9 +172,12 @@
/**
* @brief Expand to a call expression `Prefix##_argc_N(...)`, where `N` is the
* number of macro arguments.
*
* XXX: The `MLIB_JUST` forces an additional expansion pass that works around a
* bug in the old MSVC preprocessor, but is not required in a conforming preprocessor.
*/
#define MLIB_ARGC_PICK(Prefix, ...) \
MLIB_JUST (MLIB_PASTE_3 (Prefix, _argc_, MLIB_ARG_COUNT (__VA_ARGS__)) (__VA_ARGS__))
#define MLIB_ARGC_PICK(Prefix, ...) MLIB_JUST (MLIB_ARGC_PASTE (Prefix, __VA_ARGS__) (__VA_ARGS__))
#define MLIB_ARGC_PASTE(Prefix, ...) MLIB_PASTE_3 (Prefix, _argc_, MLIB_ARG_COUNT (__VA_ARGS__))

#ifdef __cplusplus
#define mlib_is_cxx() 1
Expand Down
Loading