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

@@ -10,7 +10,6 @@
#ifndef headerfilecmslucoresessioncontainer
#define headerfilecmslucoresessioncontainer
#include <list>
#include <map>
#include <ctime>
@@ -18,62 +17,58 @@
#include "session.h"
#include "lastcontainer.h"
#include "request.h"
#include "basethread.h"
#include "config.h"
class SessionContainer
class SessionContainer : public BaseThread
{
public:
// when deleting Sessions you should set request.session into the session object
// this allows to delete plugins session data
// because a session object has plugin_data object
// and in its destructor the plugin.Call(WINIX_SESSION_REMOVE) is called
typedef std::list<Session> Table;
typedef Table::iterator Iterator;
typedef Table::size_type TableSize;
typedef std::list<Session> Table;
typedef Table::iterator Iterator;
typedef std::map<long, Iterator> IndexId;
typedef std::multimap<time_t, Iterator> IndexTime;
SessionContainer();
void SetRequest(Request * prequest);
void SetConfig(Config * pconfig);
void SetLastContainer(LastContainer * plast_container);
void Clear();
size_t Size();
Iterator Begin();
Iterator End();
Session & Back();
bool PushBack(const Session & session);
Iterator FindById(long);
private:
LastContainer * last_container;
Table table;
IndexId index_id;
IndexTime index_time;
Request * request;
void DelFromIdIndex(Iterator iter);
Config * config;
//void DelFromIdIndex(Iterator iter);
virtual void Work();
bool IsSessionOutdated(const Session & s) const;
void DeleteSession(IndexId::iterator i);
// in FreeBSD implementation (GCC) list::size() has linear complexity
// so we use our own table_size with O(1)
size_t table_size;
public:
SessionContainer();
void SetRequest(Request * prequest);
void Clear();
TableSize Size();
Iterator Begin();
Iterator End();
Session & Back();
bool PushBack(const Session & session);
Iterator FindById(long);
size_t DelFirstByTimeInterval(time_t interval, size_t how_many_max, bool skip_remember_flag = true);
void UpdateLastTime(Iterator iter, time_t new_time);
};