-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use a C macro to sleep? #263
Comments
Sure |
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
Jun 13, 2022
Introduces two macros: - `SLEEP` to perform a nanosleep call with the specified amount of time expressed as nanoseconds; - `SLEEP_AND_GOTO` does the same of the above but adds also a `goto` to the specified label. Example of usage: SLEEP_AND_GOTO(1000000L,retry) is the same as { /* Sleep for 1ms */ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000000L; nanosleep(&ts, NULL); goto retry; } Close agroal#263
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
Jun 13, 2022
Introduces two macros: - `SLEEP` to perform a nanosleep call with the specified amount of time expressed as nanoseconds; - `SLEEP_AND_GOTO` does the same of the above but adds also a `goto` to the specified label. Example of usage: SLEEP_AND_GOTO(1000000L,retry) is the same as { /* Sleep for 1ms */ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000000L; nanosleep(&ts, NULL); goto retry; } Close agroal#263
fluca1978
added a commit
to fluca1978/pgagroal
that referenced
this issue
Jun 15, 2022
Introduces two macros: - `SLEEP` to perform a nanosleep call with the specified amount of time expressed as nanoseconds; - `SLEEP_AND_GOTO` does the same of the above but adds also a `goto` to the specified label. Example of usage: SLEEP_AND_GOTO(1000000L,retry) is the same as { /* Sleep for 1ms */ struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 1000000L; nanosleep(&ts, NULL); goto retry; } Close agroal#263
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this could improve code readibility: there are several places (not many) where there is a code like fhis:
such code performs a sleep and a jump, and is used when asking for a lock acquisition.
Cannot we wrap the code in a macro so that the above becomes:
Could this improve source code readibility and avoid duplication of code?
The text was updated successfully, but these errors were encountered: