Код: Выделить всё
class MyClass
{
std::binary_semaphore sem{0};
std::binary_semaphore& sem(); // just returns the semaphore
// some other members
}
< /code>
И у меня есть некоторые глобальные функции < /p>
void func1(MyClass& obj)
{
// some code
obj.sem().release();
}
void func2(MyClass& obj)
{
// some code
obj.sem().acquire();
obj.~MyCLass();
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... an-acquire
Мобильная версия