Skip to content

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.

xaedes added 3 commits March 7, 2022 19:58
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