added: Export plugin (not finished yet)

added:   ThreadManager
         all threads are connected to the ThreadManager
         they are started/stopped by the manager
changed: FunctionParser
         now we are parsing directly what is in URI
         (we were using GetParser beforehand)
         we are able to recognize ordinary URI scheme (with '?' and '#' characters)
         sample:
         http://domain.com/dir1/dir2/item/function?par1=val2&par2=val2#htmlanchor
         is the same as:
         http://domain.com/dir1/dir2/item/function/par1:val2/par2:val2#htmlanchor
         'htmlanchor' is put in Request::anchor field,
         and the default function can be used like this:
         http://domain.com/dir1/dir2/item?par1=val2&par2=val2#htmlanchor
         but there is not an equivalent in winix form
         e.g. http://domain.com/dir1/dir2/item/par1:val2/par2:val2#htmlanchor
         because 'par1:val2' would be treated as a function name
removed: GetParser
         now we don't have Request::get_tab structure
removed: CKEditorGetParser
         it is not needed now



git-svn-id: svn://ttmath.org/publicrep/winix/trunk@752 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2011-07-28 22:18:10 +00:00
parent c37c1ff812
commit 4d87359aca
51 changed files with 1646 additions and 1203 deletions

104
core/threadmanager.cpp Executable file
View File

@@ -0,0 +1,104 @@
/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2011, Tomasz Sowa
* All rights reserved.
*
*/
#include <signal.h>
#include "threadmanager.h"
#include "log.h"
ThreadManager::ThreadManager()
{
were_started = false;
}
void ThreadManager::SetSynchro(Synchro * psynchro)
{
synchro = psynchro;
}
void ThreadManager::Init()
{
sigset_t set;
sigemptyset(&set);
sigaddset(&set, SIGTERM);
sigaddset(&set, SIGINT);
// blocking SIGTERM and SIGINT
// new threads will have the signals blocked too
pthread_sigmask(SIG_BLOCK, &set, 0);
}
void ThreadManager::Add(BaseThread * pbase)
{
thread_tab.push_back(pbase);
if( were_started )
Start(thread_tab.size() - 1);
else
log << log4 << "TM: added a thread to the queue, number: " << (thread_tab.size()-1) << logend;
}
void ThreadManager::StartAll()
{
for(size_t i=0 ; i<thread_tab.size() ; ++i)
Start(i);
were_started = true;
}
void ThreadManager::Start(size_t i)
{
if( i < thread_tab.size() )
{
if( thread_tab[i]->StartThread() )
{
log << log4 << "TM: thread " << i << " (" << thread_tab[i]->ThreadId() << ") started" << logend;
}
else
{
log << log4 << "TM: cannot run a thread, thread number: " << i << logend;
}
}
}
void ThreadManager::StopAll()
{
if( !were_started )
return;
// WakeUpThread() should be used with Lock/Unlock
synchro->Lock();
for(size_t i=0 ; i<thread_tab.size() ; ++i)
thread_tab[i]->WakeUpThread();
synchro->Unlock();
for(size_t i=0 ; i<thread_tab.size() ; ++i)
{
log << log4 << "TM: waiting for thread " << i << " (" << thread_tab[i]->ThreadId() << ")" << logend;
thread_tab[i]->WaitForThread();
log << log4 << "TM: thread " << i << " terminated" << logend;
}
}