added: gc for sessions (another thread)

git-svn-id: svn://ttmath.org/publicrep/winix/trunk@693 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2010-12-07 12:52:52 +00:00
parent 7f77b6e3ec
commit 0a9cdd2f15
16 changed files with 434 additions and 393 deletions

View File

@@ -26,12 +26,13 @@ notify.o: ../core/dirs.h ../core/dircontainer.h ../notify/notify.h
notify.o: ../core/mounts.h ../core/mount.h ../core/mountparser.h
notify.o: ../core/users.h ../core/groups.h ../core/group.h ../core/loadavg.h
notify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
notify.o: ../core/system.h ../core/dirs.h ../core/synchro.h ../core/plugin.h
notify.o: ../core/pluginmsg.h ../core/sessionmanager.h
notify.o: ../functions/functions.h ../functions/functionbase.h
notify.o: ../functions/functionparser.h ../functions/adduser.h
notify.o: ../functions/cat.h ../functions/chmod.h ../functions/privchanger.h
notify.o: ../functions/chown.h ../functions/ckeditor.h ../functions/cp.h
notify.o: ../core/basethread.h ../core/system.h ../core/dirs.h
notify.o: ../core/synchro.h ../core/plugin.h ../core/pluginmsg.h
notify.o: ../core/sessionmanager.h ../functions/functions.h
notify.o: ../functions/functionbase.h ../functions/functionparser.h
notify.o: ../functions/adduser.h ../functions/cat.h ../functions/chmod.h
notify.o: ../functions/privchanger.h ../functions/chown.h
notify.o: ../functions/ckeditor.h ../functions/cp.h
notify.o: ../functions/createthread.h ../functions/default.h
notify.o: ../functions/download.h ../functions/emacs.h ../functions/last.h
notify.o: ../functions/login.h ../functions/logout.h ../functions/ls.h
@@ -108,4 +109,4 @@ templatesnotify.o: ../core/httpsimpleparser.h ../core/log.h
templatesnotify.o: ../templates/indexpatterns.h ../templates/localefilter.h
templatesnotify.o: ../templates/locale.h ../templates/htmltextstream.h
templatesnotify.o: ../core/sessionmanager.h ../core/sessioncontainer.h
templatesnotify.o: ../core/lastcontainer.h
templatesnotify.o: ../core/lastcontainer.h ../core/basethread.h

View File

@@ -19,7 +19,7 @@
Notify::Notify() : thread_signal(PTHREAD_COND_INITIALIZER)
Notify::Notify()
{
}
@@ -62,9 +62,7 @@ void Notify::Init()
notify_thread.SetUsers(users);
notify_thread.SetNotifyPool(&notify_pool);
notify_thread.SetPatterns(&patterns);
notify_thread.SetSynchro(synchro);
notify_thread.SetSignal(&thread_signal);
notify_template_cms = AddTemplate(L"notify_email_cms.txt"); // !! do konfiga
notify_template_thread = AddTemplate(L"notify_email_thread.txt");
@@ -133,7 +131,7 @@ void Notify::ItemChanged(int notify_code, const Item & item)
void Notify::ItemChanged(const NotifyMsg & msg)
{
notify_pool.Add(msg);
SendSignalToThread(); // we are in the first locked thread
notify_thread.WakeUpThread(); // we are in the first locked thread
}
@@ -145,6 +143,13 @@ void Notify::StartThread()
}
void Notify::PrepareToStopThread()
{
// synchro->was_stop_signal is true
notify_thread.WakeUpThread();
}
void Notify::WaitForThread()
{
notify_thread.WaitForThread();
@@ -186,8 +191,3 @@ static std::wstring tmp_path;
void Notify::SendSignalToThread()
{
// you should use it with: synchro->Lock() and Unlock()
pthread_cond_signal(&thread_signal);
}

View File

@@ -39,7 +39,7 @@ public:
void Init();
void StartThread();
void SendSignalToThread(); // use it in lock/unlock
void PrepareToStopThread();
void WaitForThread();
size_t AddTemplate(const std::wstring & file_name);
@@ -60,9 +60,6 @@ private:
NotifyMsg msg;
NotifyPool notify_pool;
// conditional variable
pthread_cond_t thread_signal;
size_t notify_template_cms;
size_t notify_template_thread;