Commit Graph

9 Commits

Author SHA1 Message Date
Peter Johnson
cc56bdc787 [wpiutil] SafeThread: Add Synchronization object variant (#4382)
This enables use of SafeThread with Synchronization's WaitForObjects() blocking.
2022-08-31 11:29:57 -07:00
Peter Johnson
2aed432b4b Add braces to C++ single-line loops and conditionals (NFC) (#2973)
This makes code easier to read and more consistent between C++ and Java.
Also update clang-format settings to always add a line break (even if no braces are used).
2020-12-28 12:58:06 -08:00
Peter Johnson
8f1f64ffb6 Remove year from file copyright message (NFC) (#2972)
Also update copyright to include "and other WPILib contributors" and clarify
license referral language to not be restricted to FIRST teams.
2020-12-26 14:12:05 -08:00
Tyler Veness
62be0392b6 Replace std::lock_guard and std::lock with std::scoped_lock (#1758)
std::scoped_lock was introduced in C++17 and is strictly better than
std::lock_guard as it supports locking any number of mutexes safely.
It's also easier to use than std::lock for locking multiple mutexes at
once.
2019-07-08 22:58:39 -07:00
Tyler Veness
841ef5d739 Remove template types from lock RAII wrapper usages (#1756)
C++17 has template type autodeduction. These wrappers include
std::lock_guard and std::unique_lock.
2019-07-07 19:17:14 -07:00
Peter Johnson
ee8a33c568 wpiutil: SafeThread: Add thread id, support getting shared_ptr (#1722)
Rename base class function from GetThread to GetThreadSharedPtr.
2019-06-20 19:51:09 -07:00
Peter Johnson
0a937bb5b9 wpiutil: SafeThread: Ensure thread is released in destructor (#1358)
The thread must be released with either a detach or a join, otherwise
std::terminate is called.
2018-10-06 18:07:56 -07:00
Peter Johnson
613d5eda0d wpiutil: SafeThread: join on thread exit (#1357)
This can be conditionally disabled (for cases like JNI callbacks where the JVM
may block callbacks into it during shutdown).
2018-10-06 15:17:13 -07:00
Peter Johnson
18c8cce6a7 SafeThread: Avoid use-after-free risk in thread shutdown (#1355)
Use shared_ptr to keep data alive until the thread has terminated.
2018-10-05 16:32:43 -07:00