added a special thread for making thumbnails (thumb.h thumb.cpp)

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@700 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-12-11 22:55:48 +00:00
parent e854fe3681
commit 5d09eb149c
39 changed files with 706 additions and 289 deletions

View File

@@ -17,6 +17,7 @@ BaseThread::BaseThread() : thread_signal(PTHREAD_COND_INITIALIZER)
synchro = 0;
thread_id = 0;
work_mode = 0;
wake_up_was_called = false;
}
@@ -91,6 +92,8 @@ bool BaseThread::BaseSignalReceived()
{
bool make_do = false;
wake_up_was_called = false;
try
{
make_do = SignalReceived(); // your short-time virtual method (objects are locked)
@@ -119,13 +122,18 @@ void BaseThread::BaseDo()
// use it with Lock and Unlock
bool BaseThread::WaitForSignal()
{
if( synchro->was_stop_signal || wake_up_was_called )
return true;
return pthread_cond_wait(&thread_signal, &synchro->mutex) == 0;
}
// you should use this method with: synchro->Lock() and Unlock()
void BaseThread::WakeUpThread()
{
// you should use it with: synchro->Lock() and Unlock()
wake_up_was_called = true;
pthread_cond_signal(&thread_signal);
}
@@ -168,14 +176,14 @@ bool make_do;
{
make_do = false;
if( !synchro->was_stop_signal && WaitForSignal() ) // automatically unlock, wait and lock again when signal comes
if( WaitForSignal() ) // automatically unlock, wait and lock again when signal comes
if( !synchro->was_stop_signal )
make_do = BaseSignalReceived(); // your short-time virtual method will be called (objects locked)
make_do = BaseSignalReceived(); // your short-time virtual method will be called (objects locked)
Unlock(); // unlocking from WaitForSignal()
Unlock(); // unlocking from WaitForSignal()
if( make_do )
BaseDo(); // your long-time virtual method will be called (objects *not* locked)
BaseDo(); // your long-time virtual method will be called (objects *not* locked)
}
}
while( !IsExitSignal() );