|
OpenSim Moco
0.1.0-preprint
Solve optimal control problems with OpenSim models
|
This class lets you store objects of a single type for reuse by multiple threads, ensuring threadsafe access to each of those objects.
#include <Moco/Moco/MocoUtilities.h>
Public Member Functions | |
| std::unique_ptr< T > | take () |
| Request an object for your exclusive use on your thread. More... | |
| void | leave (std::unique_ptr< T > entry) |
| Add or return an object so that another thread can use it. More... | |
| int | size () const |
| Obtain the number of entries that can be taken. | |
|
inline |
Add or return an object so that another thread can use it.
You will need to std::move() the entry, ensuring that you will no longer have access to the entry in your code (the pointer will now be null).
|
inline |
Request an object for your exclusive use on your thread.
This function blocks the thread until an object is available. Make sure to return (leave()) the object when you're done!
1.8.16