Skip to content
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

Better C++ compatibility for branch fast_lio #23

Open
wants to merge 4 commits into
base: fast_lio
Choose a base branch
from

Conversation

xaedes
Copy link

@xaedes xaedes commented Mar 10, 2022

#22

Right now the header file is "using namespace std". This is considered bad practice, but easy to fix.

Additionally <unistd.h> is used to put the current thread to sleep.
This is not platform independent, but easily replaced by C++ std library functionality.

add missing std:: namespace qualifiers.
remove unistd.h include which is only necessary for usleep but not available on all platforms.
implement usleep with c++ std libraries <thread> and <chrono>.
@xaedes
Copy link
Author

xaedes commented Mar 14, 2022

Using <pthread.h> is sometimes also problematic to build on certain platforms and can be replaced by std::thread and std::mutex.

pthread_mutex_trylock returns zero on success.
std::mutex::try_lock returns true on success.
The conditions checked for success of pthread_mutex_trylock, so they should now require result value of `true`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant