Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Store {
- public:
- std::shared_ptr<Bread> GetBread() {
- mut.lock();
- ThreadChecker checker(count_);
- ++next_id_;
- mut.unlock();
- return std::make_shared<Bread>(next_id_);
- }
- std::shared_ptr<Sausage> GetSausage() {
- mut.lock();
- ThreadChecker checker(count_);
- ++next_id_;
- mut.unlock();
- return std::make_shared<Sausage>(next_id_);
- }
- private:
- int next_id_ = 0;
- std::atomic_int count_ = 0;
- std::mutex mut;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement