Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
45bafea1
Commit
45bafea1
authored
Jan 29, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(UInterface): убрал использование "дорогого" timestamp в кэше, перешёл на подсчёт обращений.
parent
b6bccc10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
39 deletions
+10
-39
UInterface.h
include/UInterface.h
+10
-39
UInterface.cc
src/Interfaces/UInterface.cc
+0
-0
No files found.
include/UInterface.h
View file @
45bafea1
...
...
@@ -256,12 +256,12 @@ class UInterface
class
CacheOfResolve
{
public
:
CacheOfResolve
(
unsigned
int
maxsize
,
int
cleantime
)
:
MaxSize
(
maxsize
),
CleanTime
(
cleantime
){};
CacheOfResolve
(
unsigned
int
maxsize
,
int
cleancount
=
20
)
:
MaxSize
(
maxsize
),
minCallCount
(
cleancount
){};
~
CacheOfResolve
(){};
UniSetTypes
::
ObjectPtr
resolve
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
)
const
throw
(
UniSetTypes
::
NameNotFound
);
void
cache
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
,
UniSetTypes
::
ObjectVar
ptr
)
const
;
void
cache
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
,
UniSetTypes
::
ObjectVar
ptr
)
const
;
void
erase
(
const
UniSetTypes
::
ObjectId
id
,
const
UniSetTypes
::
ObjectId
node
)
const
;
inline
void
setMaxSize
(
unsigned
int
ms
)
...
...
@@ -269,66 +269,37 @@ class UInterface
MaxSize
=
ms
;
};
// void setCleanTime();
protected
:
CacheOfResolve
(){};
private
:
bool
clean
();
/*!< функция очистки кэш-а от старых ссылок */
bool
clean
();
/*!< функция очистки кэш-а от старых ссылок */
inline
void
clear
()
/*!< удаление всей информации */
{
UniSetTypes
::
uniset_rwmutex_wrlock
l
(
cmutex
);
mcache
.
clear
();
};
/*!
\todo можно добавить поле CleanTime для каждой ссылки отдельно...
*/
struct
Info
{
Info
(
UniSetTypes
::
ObjectVar
ptr
,
time_t
tm
=
0
)
:
ptr
(
ptr
)
{
if
(
!
tm
)
timestamp
=
time
(
NULL
);
}
Info
()
:
ptr
(
NULL
),
timestamp
(
0
){};
Info
(
UniSetTypes
::
ObjectVar
ptr
)
:
ptr
(
ptr
),
ncall
(
0
){}
Info
()
:
ptr
(
NULL
),
ncall
(
0
){}
UniSetTypes
::
ObjectVar
ptr
;
time_t
timestamp
;
// время последнего обращения
unsigned
long
ncall
;
// счётчик обращений
bool
operator
<
(
const
CacheOfResolve
::
Info
&
rhs
)
const
{
return
this
->
timestamp
<
rhs
.
timestamp
;
return
this
->
ncall
>
rhs
.
ncall
;
}
};
typedef
std
::
map
<
int
,
Info
>
CacheMap
;
mutable
CacheMap
mcache
;
mutable
UniSetTypes
::
uniset_rwmutex
cmutex
;
unsigned
int
MaxSize
;
/*!< максимальный размер кэша */
unsigned
int
CleanTime
;
/*!< период устаревания ссылок [мин] */
/*
// В последствии написать функцию для использования
// remove_if
typedef std::pair<int, Info> CacheItem;
// функция-объект для поиска устаревших(по времени) ссылок
struct OldRef_eq: public unary_function<CacheItem, bool>
{
OldRef_eq(time_t tm):tm(tm){}
bool operator()( const CacheItem& inf ) const
{
return inf.timestamp < tm;
}
time_t tm;
};
*/
unsigned
int
MaxSize
;
/*!< максимальный размер кэша */
unsigned
int
minCallCount
;
/*!< минимальное количество вызовов, меньше которого ссылка считается устаревшей */
};
void
initBackId
(
UniSetTypes
::
ObjectId
backid
);
...
...
src/Interfaces/UInterface.cc
View file @
45bafea1
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment