D
Diego Martins
consider the following piece of code:
void MyClass::VideoThreadLocker:perator()(Threadable * thread) {
static_cast<BasicVideoThread *>(thread)->mutex.lock();
};
void MyClass::VideoThreadUnlocker:perator()(Threadable * thread) {
static_cast<BasicVideoThread *>(thread)->mutex.unlock();
};
void MyClass:rocessData(PipeData & data)
{
std::for_each(threads.begin(),threads.end(),VideoThreadLocker());
cond.signalAll();
...
std::for_each(threads.begin(),threads.end(),VideoThreadUnlocker());
}
is there a way to avoid the creation of classes VideoThreadLocker and
VideoThreadUnlocker?
I can't figure out how to use mem_fun and binders in order to achieve
the static_cast and reach mutex.lock() or mutex.unlock()
is pointers to member-functions a good alternative? Using this, I will
create one additional class (e.g.: MutexThreadOper), intead of the two
current classes
cheers
Diego Martins
void MyClass::VideoThreadLocker:perator()(Threadable * thread) {
static_cast<BasicVideoThread *>(thread)->mutex.lock();
};
void MyClass::VideoThreadUnlocker:perator()(Threadable * thread) {
static_cast<BasicVideoThread *>(thread)->mutex.unlock();
};
void MyClass:rocessData(PipeData & data)
{
std::for_each(threads.begin(),threads.end(),VideoThreadLocker());
cond.signalAll();
...
std::for_each(threads.begin(),threads.end(),VideoThreadUnlocker());
}
is there a way to avoid the creation of classes VideoThreadLocker and
VideoThreadUnlocker?
I can't figure out how to use mem_fun and binders in order to achieve
the static_cast and reach mutex.lock() or mutex.unlock()
is pointers to member-functions a good alternative? Using this, I will
create one additional class (e.g.: MutexThreadOper), intead of the two
current classes
cheers
Diego Martins