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
99dc6b5d
Commit
99dc6b5d
authored
Feb 24, 2011
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Local timers): Оптимизировал код. Убрал не нужную сортировку
(всё-равно по всему списку таймеров проходим)
parent
cb5350a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
libuniset.spec
conf/libuniset.spec
+7
-1
LT_Object.cc
src/Various/LT_Object.cc
+14
-17
No files found.
conf/libuniset.spec
View file @
99dc6b5d
...
...
@@ -3,7 +3,7 @@
Name: libuniset
Version: 1.0
Release: alt
4
Release: alt
5
Summary: UniSet - library for building distributed industrial control systems
License: GPL
Group: Development/C++
...
...
@@ -187,6 +187,12 @@ rm -f %buildroot%_libdir/*.la
%exclude %_pkgconfigdir/libUniSet.pc
%changelog
* Thu Feb 24 2011 Pavel Vainerman <pv@server> 1.0-alt5
- new build (optimization local timers)
* Thu Feb 24 2011 Pavel Vainerman <pv@server> 1.0-alt4
- new build
* Mon Feb 14 2011 Pavel Vainerman <pv@server> 1.0-alt3
- fixed bug in ModbusTCPMaster
...
...
src/Various/LT_Object.cc
View file @
99dc6b5d
...
...
@@ -27,22 +27,22 @@
#include "LT_Object.h"
#include "Debug.h"
// -----------------------------------------------------------------------------
-------------
// -----------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
// -----------------------------------------------------------------------------
-------------
// -----------------------------------------------------------------------------
LT_Object
::
LT_Object
()
:
sleepTime
(
UniSetTimer
::
WaitUpTime
)
{
tmLast
.
setTiming
(
UniSetTimer
::
WaitUpTime
);
}
// -----------------------------------------------------------------------------
-------------
// -----------------------------------------------------------------------------
LT_Object
::~
LT_Object
()
{
}
// -----------------------------------------------------------------------------
-------------
// -----------------------------------------------------------------------------
timeout_t
LT_Object
::
checkTimers
(
UniSetObject
*
obj
)
{
try
...
...
@@ -71,7 +71,6 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
{
// lock
uniset_mutex_lock
lock
(
lstMutex
,
5000
);
bool
resort
(
false
);
sleepTime
=
UniSetTimer
::
WaitUpTime
;
for
(
TimersList
::
iterator
li
=
tlst
.
begin
();
li
!=
tlst
.
end
();
++
li
)
{
...
...
@@ -93,7 +92,6 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
li
->
curTick
--
;
li
->
reset
();
resort
=
true
;
}
else
{
...
...
@@ -105,9 +103,6 @@ timeout_t LT_Object::checkTimers( UniSetObject* obj )
sleepTime
=
li
->
curTimeMS
;
}
if
(
resort
)
// пересортировываем в связи с обновлением списка
tlst
.
sort
();
if
(
sleepTime
<
UniSetTimer
::
MinQuantityTime
)
sleepTime
=
UniSetTimer
::
MinQuantityTime
;
}
// unlock
...
...
@@ -135,7 +130,7 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
}
{
// lock
if
(
!
lstMutex
.
isRelease
()
&&
unideb
.
debugging
(
Debug
::
INFO
)
)
if
(
unideb
.
debugging
(
Debug
::
INFO
)
&&
!
lstMutex
.
isRelease
(
)
)
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): придется подождать освобождения lstMutex-а"
<<
endl
;
uniset_mutex_lock
lock
(
lstMutex
,
2000
);
...
...
@@ -148,8 +143,11 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
{
li
->
curTick
=
ticks
;
li
->
tmr
.
setTiming
(
timeMS
);
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): заказ на таймер(id="
<<
timerid
<<
") "
<<
timeMS
<<
" [мс] уже есть...
\n
"
;
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
{
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): заказ на таймер(id="
<<
timerid
<<
") "
<<
timeMS
<<
" [мс] уже есть..."
<<
endl
;
}
return
sleepTime
;
}
}
...
...
@@ -157,7 +155,6 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
TimerInfo
newti
(
timerid
,
timeMS
,
ticks
,
p
);
tlst
.
push_back
(
newti
);
tlst
.
sort
();
newti
.
reset
();
}
// unlock
...
...
@@ -169,17 +166,17 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): поступил отказ по таймеру id="
<<
timerid
<<
endl
;
{
// lock
if
(
!
lstMutex
.
isRelease
()
&&
unideb
.
debugging
(
Debug
::
INFO
)
)
if
(
unideb
.
debugging
(
Debug
::
INFO
)
&&
!
lstMutex
.
isRelease
(
)
)
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): придется подождать освобождения lstMutex-а
\n
"
;
uniset_mutex_lock
lock
(
lstMutex
,
2000
);
tlst
.
remove_if
(
Timer_eq
(
timerid
));
// STL - способ
tlst
.
sort
();
}
// unlock
}
{
// lock
if
(
!
lstMutex
.
isRelease
()
&&
unideb
.
debugging
(
Debug
::
INFO
)
)
if
(
unideb
.
debugging
(
Debug
::
INFO
)
&&
!
lstMutex
.
isRelease
(
)
)
unideb
[
Debug
::
INFO
]
<<
"(LT_askTimer): придется подождать освобождения lstMutex-а
\n
"
;
uniset_mutex_lock
lock
(
lstMutex
,
2000
);
...
...
@@ -192,4 +189,4 @@ timeout_t LT_Object::askTimer( UniSetTypes::TimerId timerid, timeout_t timeMS, c
return
sleepTime
;
}
// -----------------------------------------------------------------------------
-------------
// -----------------------------------------------------------------------------
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