MCPcopy Create free account
hub / github.com/Artikash/Textractor / Synchronized

Class Synchronized

include/common.h:57–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

55
56template<typename T, typename M = std::mutex>
57class Synchronized
58{
59public:
60 template <typename... Args>
61 Synchronized(Args&&... args) : contents(std::forward<Args>(args)...) {}
62
63 struct Locker
64 {
65 T* operator->() { return &contents; }
66 std::unique_lock<M> lock;
67 T& contents;
68 };
69
70 Locker Acquire() { return { std::unique_lock(m), contents }; }
71 Locker operator->() { return Acquire(); }
72 T Copy() { return Acquire().contents; }
73
74private:
75 T contents;
76 M m;
77};
78
79template <typename F>
80void SpawnThread(const F& f) // works in DllMain unlike std thread

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected