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
705d6b82
Commit
705d6b82
authored
Jan 27, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Перешёл где можно от mutex к atomic.
parent
c377d11b
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
97 additions
and
105 deletions
+97
-105
ctl-cpp-common.xsl
Utilities/codegen/ctl-cpp-common.xsl
+7
-7
Makefile.am
Utilities/codegen/tests/Makefile.am
+4
-4
IOControl.cc
extensions/IOControl/IOControl.cc
+7
-7
IOControl.h
extensions/IOControl/IOControl.h
+2
-2
MBExchange.cc
extensions/ModbusMaster/MBExchange.cc
+9
-11
MBExchange.h
extensions/ModbusMaster/MBExchange.h
+5
-6
MBSlave.cc
extensions/ModbusSlave/MBSlave.cc
+8
-8
MBSlave.h
extensions/ModbusSlave/MBSlave.h
+3
-3
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+5
-5
UNetExchange.h
extensions/UNetUDP/UNetExchange.h
+1
-1
UNetReceiver.cc
extensions/UNetUDP/UNetReceiver.cc
+3
-6
UNetReceiver.h
extensions/UNetUDP/UNetReceiver.h
+2
-2
UNetSender.cc
extensions/UNetUDP/UNetSender.cc
+3
-3
UNetSender.h
extensions/UNetUDP/UNetSender.h
+2
-2
UObject_SK.h
extensions/include/UObject_SK.h
+2
-2
UObject_SK.cc
extensions/lib/UObject_SK.cc
+6
-6
Makefile.am
extensions/tests/SMemoryTest/Makefile.am
+2
-2
Mutex.h
include/Mutex.h
+6
-6
PassiveTimer.h
include/PassiveTimer.h
+2
-2
ModbusRTUMaster.cc
src/Communications/Modbus/ModbusRTUMaster.cc
+2
-2
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+1
-1
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+4
-5
Mutex.cc
src/Various/Mutex.cc
+11
-12
No files found.
Utilities/codegen/ctl-cpp-common.xsl
View file @
705d6b82
...
@@ -234,7 +234,7 @@
...
@@ -234,7 +234,7 @@
inline const std::string getProp(const std::string
&
name) { return UniSetTypes::conf->getProp(confnode, name); }
inline const std::string getProp(const std::string
&
name) { return UniSetTypes::conf->getProp(confnode, name); }
int smReadyTimeout; /*!
<
время ожидания готовности SM */
int smReadyTimeout; /*!
<
время ожидания готовности SM */
bool
activated;
UniSetTypes::mutex_atomic_t
activated;
int activateTimeout; /*!
<
время ожидания готовности UniSetObject к работе */
int activateTimeout; /*!
<
время ожидания готовности UniSetObject к работе */
PassiveTimer ptStartUpTimeout; /*!
<
время на блокировку обработки WatchDog, если недавно был StartUp */
PassiveTimer ptStartUpTimeout; /*!
<
время на блокировку обработки WatchDog, если недавно был StartUp */
int askPause; /*!
<
пауза между неудачными попытками заказать датчики */
int askPause; /*!
<
пауза между неудачными попытками заказать датчики */
...
@@ -350,10 +350,10 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::activateObject()
...
@@ -350,10 +350,10 @@ bool <xsl:value-of select="$CLASSNAME"/>_SK::activateObject()
// пока не пройдёт инициализация датчиков
// пока не пройдёт инициализация датчиков
// см. sysCommand()
// см. sysCommand()
{
{
activated =
false
;
activated =
0
;
<xsl:if
test=
"normalize-space($BASECLASS)!=''"
><xsl:value-of
select=
"normalize-space($BASECLASS)"
/>
::activateObject();
</xsl:if>
<xsl:if
test=
"normalize-space($BASECLASS)!=''"
><xsl:value-of
select=
"normalize-space($BASECLASS)"
/>
::activateObject();
</xsl:if>
<xsl:if
test=
"normalize-space($BASECLASS)=''"
>
UniSetObject::activateObject();
</xsl:if>
<xsl:if
test=
"normalize-space($BASECLASS)=''"
>
UniSetObject::activateObject();
</xsl:if>
activated =
true
;
activated =
1
;
}
}
return true;
return true;
...
@@ -522,7 +522,7 @@ idHeartBeat(DefaultObjectId),
...
@@ -522,7 +522,7 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
maxHeartBeat(10),
confnode(0),
confnode(0),
smReadyTimeout(0),
smReadyTimeout(0),
activated(
false
),
activated(
0
),
askPause(2000),
askPause(2000),
<xsl:for-each
select=
"//variables/item"
>
<xsl:for-each
select=
"//variables/item"
>
<xsl:if
test=
"normalize-space(@private)!=''"
>
<xsl:if
test=
"normalize-space(@private)!=''"
>
...
@@ -586,7 +586,7 @@ idHeartBeat(DefaultObjectId),
...
@@ -586,7 +586,7 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
maxHeartBeat(10),
confnode(cnode),
confnode(cnode),
smReadyTimeout(0),
smReadyTimeout(0),
activated(
false
),
activated(
0
),
askPause(conf->getPIntProp(cnode,"askPause",2000)),
askPause(conf->getPIntProp(cnode,"askPause",2000)),
<xsl:for-each
select=
"//variables/item"
>
<xsl:for-each
select=
"//variables/item"
>
<xsl:if
test=
"normalize-space(@private)!=''"
>
<xsl:if
test=
"normalize-space(@private)!=''"
>
...
@@ -872,7 +872,7 @@ idLocalTestMode_S(DefaultObjectId),
...
@@ -872,7 +872,7 @@ idLocalTestMode_S(DefaultObjectId),
idHeartBeat(DefaultObjectId),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
maxHeartBeat(10),
confnode(0),
confnode(0),
activated(
false
),
activated(
0
),
askPause(2000)
askPause(2000)
{
{
ucrit
<<
"
<xsl:value-of
select=
"$CLASSNAME"
/>
: init failed!!!!!!!!!!!!!!!"
<<
endl;
ucrit
<<
"
<xsl:value-of
select=
"$CLASSNAME"
/>
: init failed!!!!!!!!!!!!!!!"
<<
endl;
...
@@ -906,7 +906,7 @@ in_LocalTestMode_S(false),
...
@@ -906,7 +906,7 @@ in_LocalTestMode_S(false),
idHeartBeat(DefaultObjectId),
idHeartBeat(DefaultObjectId),
maxHeartBeat(10),
maxHeartBeat(10),
confnode(cnode),
confnode(cnode),
activated(
false
),
activated(
0
),
askPause(conf->getPIntProp(cnode,"askPause",2000))
askPause(conf->getPIntProp(cnode,"askPause",2000))
{
{
if( getId() == DefaultObjectId )
if( getId() == DefaultObjectId )
...
...
Utilities/codegen/tests/Makefile.am
View file @
705d6b82
noinst_PROGRAMS
=
test
test2
noinst_PROGRAMS
=
test
test2
#test2
#test2
test_LDADD
=
$(top_builddir)
/lib/libUniSet.la
test_LDADD
=
$(top_builddir)
/lib/libUniSet.la
$(COMCPP_LIBS)
test_CXXFLAGS
=
-I
$(top_builddir)
/include
test_CXXFLAGS
=
-I
$(top_builddir)
/include
$(COMCPP_CGLAGS)
test_SOURCES
=
TestGen_SK.cc TestGen.cc TestGen-main.cc
test_SOURCES
=
TestGen_SK.cc TestGen.cc TestGen-main.cc
test2_LDADD
=
$(top_builddir)
/lib/libUniSet.la
test2_LDADD
=
$(top_builddir)
/lib/libUniSet.la
$(COMCPP_LIBS)
test2_CXXFLAGS
=
-I
$(top_builddir)
/include
test2_CXXFLAGS
=
-I
$(top_builddir)
/include
$(COMCPP_CGLAGS)
test2_SOURCES
=
TestGenAlone_SK.cc TestGenAlone.cc TestGenAlone-main.cc
test2_SOURCES
=
TestGenAlone_SK.cc TestGenAlone.cc TestGenAlone-main.cc
GENERATED
=
TestGen_SK.h TestGen_SK.cc TestGen-main.cc
GENERATED
=
TestGen_SK.h TestGen_SK.cc TestGen-main.cc
...
...
extensions/IOControl/IOControl.cc
View file @
705d6b82
...
@@ -14,10 +14,10 @@ std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf )
...
@@ -14,10 +14,10 @@ std::ostream& operator<<( std::ostream& os, IOControl::IOInfo& inf )
<<
" card="
<<
inf
.
ncard
<<
" channel="
<<
inf
.
channel
<<
" subdev="
<<
inf
.
subdev
<<
" card="
<<
inf
.
ncard
<<
" channel="
<<
inf
.
channel
<<
" subdev="
<<
inf
.
subdev
<<
" aref="
<<
inf
.
aref
<<
" range="
<<
inf
.
range
<<
" aref="
<<
inf
.
aref
<<
" range="
<<
inf
.
range
<<
" default="
<<
inf
.
defval
<<
" safety="
<<
inf
.
safety
;
<<
" default="
<<
inf
.
defval
<<
" safety="
<<
inf
.
safety
;
if
(
inf
.
cal
.
minRaw
!=
inf
.
cal
.
maxRaw
)
if
(
inf
.
cal
.
minRaw
!=
inf
.
cal
.
maxRaw
)
os
<<
inf
.
cal
;
os
<<
inf
.
cal
;
return
os
;
return
os
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -43,7 +43,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
...
@@ -43,7 +43,7 @@ IOControl::IOControl( UniSetTypes::ObjectId id, UniSetTypes::ObjectId icID,
force
(
false
),
force
(
false
),
force_out
(
false
),
force_out
(
false
),
maxCardNum
(
10
),
maxCardNum
(
10
),
activated
(
false
),
activated
(
0
),
readconf_ok
(
false
),
readconf_ok
(
false
),
term
(
false
),
term
(
false
),
testMode_as
(
UniSetTypes
::
DefaultObjectId
),
testMode_as
(
UniSetTypes
::
DefaultObjectId
),
...
@@ -295,7 +295,7 @@ void IOControl::execute()
...
@@ -295,7 +295,7 @@ void IOControl::execute()
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(execute): wait activate..."
<<
endl
;
cout
<<
myname
<<
"(execute): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
activated
)
...
@@ -783,9 +783,9 @@ bool IOControl::activateObject()
...
@@ -783,9 +783,9 @@ bool IOControl::activateObject()
// пока не пройдёт инициализация датчиков
// пока не пройдёт инициализация датчиков
// см. sysCommand()
// см. sysCommand()
{
{
activated
=
false
;
activated
=
0
;
UniSetObject
::
activateObject
();
UniSetObject
::
activateObject
();
activated
=
true
;
activated
=
1
;
}
}
return
true
;
return
true
;
...
@@ -1162,7 +1162,7 @@ void IOControl::sysCommand( const SystemMessage* sm )
...
@@ -1162,7 +1162,7 @@ void IOControl::sysCommand( const SystemMessage* sm )
{
{
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
dinfo
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
dinfo
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
activated
)
...
...
extensions/IOControl/IOControl.h
View file @
705d6b82
...
@@ -368,9 +368,9 @@ class IOControl:
...
@@ -368,9 +368,9 @@ class IOControl:
int
smReadyTimeout
;
/*!< время ожидания готовности SM к работе, мсек */
int
smReadyTimeout
;
/*!< время ожидания готовности SM к работе, мсек */
int
defCardNum
;
/*!< номер карты по умолчанию */
int
defCardNum
;
/*!< номер карты по умолчанию */
int
maxCardNum
;
/*! максимально разрешённый номер для карты */
int
maxCardNum
;
/*! максимально разрешённый номер для карты */
UniSetTypes
::
uniset_mutex
iopollMutex
;
UniSetTypes
::
uniset_mutex
iopollMutex
;
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
bool
readconf_ok
;
bool
readconf_ok
;
int
activateTimeout
;
int
activateTimeout
;
UniSetTypes
::
ObjectId
sidTestSMReady
;
UniSetTypes
::
ObjectId
sidTestSMReady
;
...
...
extensions/ModbusMaster/MBExchange.cc
View file @
705d6b82
...
@@ -22,7 +22,7 @@ force_out(false),
...
@@ -22,7 +22,7 @@ force_out(false),
mbregFromID
(
false
),
mbregFromID
(
false
),
sidExchangeMode
(
DefaultObjectId
),
sidExchangeMode
(
DefaultObjectId
),
exchangeMode
(
emNone
),
exchangeMode
(
emNone
),
activated
(
false
),
activated
(
0
),
noQueryOptimization
(
false
),
noQueryOptimization
(
false
),
no_extimer
(
false
),
no_extimer
(
false
),
prefix
(
prefix
),
prefix
(
prefix
),
...
@@ -221,14 +221,12 @@ void MBExchange::step()
...
@@ -221,14 +221,12 @@ void MBExchange::step()
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
bool
MBExchange
::
checkProcActive
()
bool
MBExchange
::
checkProcActive
()
{
{
uniset_rwmutex_rlock
l
(
actMutex
);
return
activated
;
return
activated
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
MBExchange
::
setProcActive
(
bool
st
)
void
MBExchange
::
setProcActive
(
bool
st
)
{
{
uniset_rwmutex_wrlock
l
(
actMutex
);
activated
=
(
st
?
1
:
0
);
activated
=
st
;
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
MBExchange
::
sigterm
(
int
signo
)
void
MBExchange
::
sigterm
(
int
signo
)
...
@@ -2406,15 +2404,15 @@ void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
...
@@ -2406,15 +2404,15 @@ void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
// см. activateObject()
// см. activateObject()
msleep
(
initPause
);
msleep
(
initPause
);
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
checkProcActive
()
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
checkProcActive
()
)
break
;
break
;
}
}
if
(
!
activated
)
if
(
!
checkProcActive
()
)
dcrit
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
dcrit
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
{
{
UniSetTypes
::
uniset_rwmutex_rlock
l
(
mutex_start
);
UniSetTypes
::
uniset_rwmutex_rlock
l
(
mutex_start
);
...
@@ -2432,7 +2430,7 @@ void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
...
@@ -2432,7 +2430,7 @@ void MBExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
case
SystemMessage
:
:
Finish
:
case
SystemMessage
:
:
Finish
:
askSensors
(
UniversalIO
::
UIODontNotify
);
askSensors
(
UniversalIO
::
UIODontNotify
);
break
;
break
;
case
SystemMessage
:
:
WatchDog
:
case
SystemMessage
:
:
WatchDog
:
{
{
// ОПТИМИЗАЦИЯ (защита от двойного перезаказа при старте)
// ОПТИМИЗАЦИЯ (защита от двойного перезаказа при старте)
...
@@ -2695,7 +2693,7 @@ void MBExchange::poll()
...
@@ -2695,7 +2693,7 @@ void MBExchange::poll()
if
(
d
->
resp_real
)
if
(
d
->
resp_real
)
allNotRespond
=
false
;
allNotRespond
=
false
;
if
(
it
==
d
->
regmap
.
end
()
)
if
(
it
==
d
->
regmap
.
end
()
)
break
;
break
;
...
@@ -2724,7 +2722,7 @@ void MBExchange::poll()
...
@@ -2724,7 +2722,7 @@ void MBExchange::poll()
// update SharedMemory...
// update SharedMemory...
updateSM
();
updateSM
();
// check thresholds
// check thresholds
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
for
(
MBExchange
::
RTUDeviceMap
::
iterator
it1
=
rmap
.
begin
();
it1
!=
rmap
.
end
();
++
it1
)
{
{
...
...
extensions/ModbusMaster/MBExchange.h
View file @
705d6b82
...
@@ -248,7 +248,7 @@ class MBExchange:
...
@@ -248,7 +248,7 @@ class MBExchange:
bool
checkUpdateSM
(
bool
wrFunc
,
long
devMode
);
bool
checkUpdateSM
(
bool
wrFunc
,
long
devMode
);
bool
checkPoll
(
bool
wrFunc
);
bool
checkPoll
(
bool
wrFunc
);
bool
checkProcActive
();
bool
checkProcActive
();
void
setProcActive
(
bool
st
);
void
setProcActive
(
bool
st
);
void
waitSMReady
();
void
waitSMReady
();
...
@@ -298,20 +298,19 @@ class MBExchange:
...
@@ -298,20 +298,19 @@ class MBExchange:
IOController
::
IOStateList
::
iterator
itExchangeMode
;
IOController
::
IOStateList
::
iterator
itExchangeMode
;
long
exchangeMode
;
/*!< режим работы см. ExchangeMode */
long
exchangeMode
;
/*!< режим работы см. ExchangeMode */
UniSetTypes
::
uniset_rwmutex
actMutex
;
UniSetTypes
::
mutex_atomic_t
activated
;
bool
activated
;
int
activateTimeout
;
int
activateTimeout
;
bool
noQueryOptimization
;
bool
noQueryOptimization
;
bool
no_extimer
;
bool
no_extimer
;
std
::
string
prefix
;
std
::
string
prefix
;
timeout_t
stat_time
;
/*!< время сбора статистики обмена */
timeout_t
stat_time
;
/*!< время сбора статистики обмена */
int
poll_count
;
int
poll_count
;
PassiveTimer
ptStatistic
;
/*!< таймер для сбора статистики обмена */
PassiveTimer
ptStatistic
;
/*!< таймер для сбора статистики обмена */
std
::
string
prop_prefix
;
/*!< префикс для считывания параметров обмена */
std
::
string
prop_prefix
;
/*!< префикс для считывания параметров обмена */
ModbusClient
*
mb
;
ModbusClient
*
mb
;
// определение timeout для соединения
// определение timeout для соединения
...
...
extensions/ModbusSlave/MBSlave.cc
View file @
705d6b82
...
@@ -22,7 +22,7 @@ askcount_id(DefaultObjectId),
...
@@ -22,7 +22,7 @@ askcount_id(DefaultObjectId),
respond_id
(
DefaultObjectId
),
respond_id
(
DefaultObjectId
),
respond_invert
(
false
),
respond_invert
(
false
),
askCount
(
0
),
askCount
(
0
),
activated
(
false
),
activated
(
0
),
activateTimeout
(
500
),
activateTimeout
(
500
),
pingOK
(
true
),
pingOK
(
true
),
force
(
false
),
force
(
false
),
...
@@ -549,7 +549,7 @@ void MBSlave::sysCommand( const UniSetTypes::SystemMessage *sm )
...
@@ -549,7 +549,7 @@ void MBSlave::sysCommand( const UniSetTypes::SystemMessage *sm )
msleep
(
initPause
);
msleep
(
initPause
);
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
activated
)
...
@@ -557,9 +557,9 @@ void MBSlave::sysCommand( const UniSetTypes::SystemMessage *sm )
...
@@ -557,9 +557,9 @@ void MBSlave::sysCommand( const UniSetTypes::SystemMessage *sm )
}
}
if
(
!
activated
)
if
(
!
activated
)
{
{
dcrit
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
dcrit
<<
myname
<<
"(sysCommand): ************* don`t activate?! ************"
<<
endl
;
}
}
else
else
{
{
UniSetTypes
::
uniset_rwmutex_rlock
l
(
mutex_start
);
UniSetTypes
::
uniset_rwmutex_rlock
l
(
mutex_start
);
...
@@ -699,11 +699,11 @@ bool MBSlave::activateObject()
...
@@ -699,11 +699,11 @@ bool MBSlave::activateObject()
// пока не пройдёт инициализация датчиков
// пока не пройдёт инициализация датчиков
// см. sysCommand()
// см. sysCommand()
{
{
activated
=
false
;
activated
=
0
;
UniSetTypes
::
uniset_rwmutex_wrlock
l
(
mutex_start
);
UniSetTypes
::
uniset_rwmutex_wrlock
l
(
mutex_start
);
UniSetObject_LT
::
activateObject
();
UniSetObject_LT
::
activateObject
();
initIterators
();
initIterators
();
activated
=
true
;
activated
=
1
;
}
}
return
true
;
return
true
;
...
@@ -711,8 +711,8 @@ bool MBSlave::activateObject()
...
@@ -711,8 +711,8 @@ bool MBSlave::activateObject()
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
void
MBSlave
::
sigterm
(
int
signo
)
void
MBSlave
::
sigterm
(
int
signo
)
{
{
cerr
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
dinfo
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
activated
=
false
;
activated
=
0
;
try
try
{
{
if
(
mbslot
)
if
(
mbslot
)
...
...
extensions/ModbusSlave/MBSlave.h
View file @
705d6b82
...
@@ -188,8 +188,8 @@ class MBSlave:
...
@@ -188,8 +188,8 @@ class MBSlave:
long
askCount
;
long
askCount
;
typedef
std
::
map
<
ModbusRTU
::
mbErrCode
,
unsigned
int
>
ExchangeErrorMap
;
typedef
std
::
map
<
ModbusRTU
::
mbErrCode
,
unsigned
int
>
ExchangeErrorMap
;
ExchangeErrorMap
errmap
;
/*!< статистика обмена */
ExchangeErrorMap
errmap
;
/*!< статистика обмена */
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
int
activateTimeout
;
int
activateTimeout
;
bool
pingOK
;
bool
pingOK
;
timeout_t
wait_msec
;
timeout_t
wait_msec
;
...
@@ -200,7 +200,7 @@ class MBSlave:
...
@@ -200,7 +200,7 @@ class MBSlave:
typedef
std
::
map
<
int
,
std
::
string
>
FileList
;
typedef
std
::
map
<
int
,
std
::
string
>
FileList
;
FileList
flist
;
FileList
flist
;
std
::
string
prefix
;
std
::
string
prefix
;
ModbusRTU
::
ModbusData
buf
[
ModbusRTU
::
MAXLENPACKET
/
2
+
1
];
/*!< буфер для формирования ответов */
ModbusRTU
::
ModbusData
buf
[
ModbusRTU
::
MAXLENPACKET
/
2
+
1
];
/*!< буфер для формирования ответов */
// данные для ответа на запрос 0x2B(43)/0x0E(14)
// данные для ответа на запрос 0x2B(43)/0x0E(14)
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
705d6b82
...
@@ -11,7 +11,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
...
@@ -11,7 +11,7 @@ UNetExchange::UNetExchange( UniSetTypes::ObjectId objId, UniSetTypes::ObjectId s
UniSetObject_LT
(
objId
),
UniSetObject_LT
(
objId
),
shm
(
0
),
shm
(
0
),
initPause
(
0
),
initPause
(
0
),
activated
(
false
),
activated
(
0
),
no_sender
(
false
),
no_sender
(
false
),
sender
(
0
),
sender
(
0
),
sender2
(
0
)
sender2
(
0
)
...
@@ -473,7 +473,7 @@ void UNetExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
...
@@ -473,7 +473,7 @@ void UNetExchange::sysCommand( const UniSetTypes::SystemMessage *sm )
msleep
(
initPause
);
msleep
(
initPause
);
PassiveTimer
ptAct
(
activateTimeout
);
PassiveTimer
ptAct
(
activateTimeout
);
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
while
(
!
activated
&&
!
ptAct
.
checkTime
()
)
{
{
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
cout
<<
myname
<<
"(sysCommand): wait activate..."
<<
endl
;
msleep
(
300
);
msleep
(
300
);
if
(
activated
)
if
(
activated
)
...
@@ -576,11 +576,11 @@ bool UNetExchange::activateObject()
...
@@ -576,11 +576,11 @@ bool UNetExchange::activateObject()
// пока не пройдёт инициализация датчиков
// пока не пройдёт инициализация датчиков
// см. sysCommand()
// см. sysCommand()
{
{
activated
=
false
;
activated
=
0
;
UniSetTypes
::
uniset_rwmutex_wrlock
l
(
mutex_start
);
UniSetTypes
::
uniset_rwmutex_wrlock
l
(
mutex_start
);
UniSetObject_LT
::
activateObject
();
UniSetObject_LT
::
activateObject
();
initIterators
();
initIterators
();
activated
=
true
;
activated
=
1
;
}
}
return
true
;
return
true
;
...
@@ -589,7 +589,7 @@ bool UNetExchange::activateObject()
...
@@ -589,7 +589,7 @@ bool UNetExchange::activateObject()
void
UNetExchange
::
sigterm
(
int
signo
)
void
UNetExchange
::
sigterm
(
int
signo
)
{
{
dinfo
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
dinfo
<<
myname
<<
": ********* SIGTERM("
<<
signo
<<
") ********"
<<
endl
;
activated
=
false
;
activated
=
0
;
for
(
ReceiverList
::
iterator
it
=
recvlist
.
begin
();
it
!=
recvlist
.
end
();
++
it
)
for
(
ReceiverList
::
iterator
it
=
recvlist
.
begin
();
it
!=
recvlist
.
end
();
++
it
)
{
{
try
try
...
...
extensions/UNetUDP/UNetExchange.h
View file @
705d6b82
...
@@ -134,7 +134,7 @@ class UNetExchange:
...
@@ -134,7 +134,7 @@ class UNetExchange:
int
steptime
;
/*!< периодичность вызова step, [мсек] */
int
steptime
;
/*!< периодичность вызова step, [мсек] */
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
int
activateTimeout
;
int
activateTimeout
;
struct
ReceiverInfo
struct
ReceiverInfo
...
...
extensions/UNetUDP/UNetReceiver.cc
View file @
705d6b82
...
@@ -31,7 +31,7 @@ lostPackets(0),
...
@@ -31,7 +31,7 @@ lostPackets(0),
sidRespond
(
UniSetTypes
::
DefaultObjectId
),
sidRespond
(
UniSetTypes
::
DefaultObjectId
),
respondInvert
(
false
),
respondInvert
(
false
),
sidLostPackets
(
UniSetTypes
::
DefaultObjectId
),
sidLostPackets
(
UniSetTypes
::
DefaultObjectId
),
activated
(
false
),
activated
(
0
),
r_thr
(
0
),
r_thr
(
0
),
u_thr
(
0
),
u_thr
(
0
),
pnum
(
0
),
pnum
(
0
),
...
@@ -160,7 +160,7 @@ void UNetReceiver::start()
...
@@ -160,7 +160,7 @@ void UNetReceiver::start()
{
{
if
(
!
activated
)
if
(
!
activated
)
{
{
activated
=
true
;
activated
=
1
;
u_thr
->
start
();
u_thr
->
start
();
r_thr
->
start
();
r_thr
->
start
();
}
}
...
@@ -348,10 +348,7 @@ void UNetReceiver::real_update()
...
@@ -348,10 +348,7 @@ void UNetReceiver::real_update()
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
stop
()
void
UNetReceiver
::
stop
()
{
{
activated
=
false
;
activated
=
0
;
// msleep(10);
// u_thr->stop();
// r_thr->stop();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetReceiver
::
receive
()
void
UNetReceiver
::
receive
()
...
...
extensions/UNetUDP/UNetReceiver.h
View file @
705d6b82
...
@@ -130,8 +130,8 @@ class UNetReceiver
...
@@ -130,8 +130,8 @@ class UNetReceiver
UniSetTypes
::
ObjectId
sidLostPackets
;
UniSetTypes
::
ObjectId
sidLostPackets
;
IOController
::
IOStateList
::
iterator
itLostPackets
;
IOController
::
IOStateList
::
iterator
itLostPackets
;
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
ThreadCreator
<
UNetReceiver
>*
r_thr
;
// receive thread
ThreadCreator
<
UNetReceiver
>*
r_thr
;
// receive thread
ThreadCreator
<
UNetReceiver
>*
u_thr
;
// update thread
ThreadCreator
<
UNetReceiver
>*
u_thr
;
// update thread
...
...
extensions/UNetUDP/UNetSender.cc
View file @
705d6b82
...
@@ -15,7 +15,7 @@ s_fvalue(s_val),
...
@@ -15,7 +15,7 @@ s_fvalue(s_val),
shm
(
smi
),
shm
(
smi
),
s_host
(
s_host
),
s_host
(
s_host
),
sendpause
(
150
),
sendpause
(
150
),
activated
(
false
),
activated
(
0
),
dlist
(
100
),
dlist
(
100
),
maxItem
(
0
),
maxItem
(
0
),
packetnum
(
1
),
packetnum
(
1
),
...
@@ -195,7 +195,7 @@ void UNetSender::real_send()
...
@@ -195,7 +195,7 @@ void UNetSender::real_send()
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
UNetSender
::
stop
()
void
UNetSender
::
stop
()
{
{
activated
=
false
;
activated
=
0
;
// s_thr->stop();
// s_thr->stop();
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -203,7 +203,7 @@ void UNetSender::start()
...
@@ -203,7 +203,7 @@ void UNetSender::start()
{
{
if
(
!
activated
)
if
(
!
activated
)
{
{
activated
=
true
;
activated
=
1
;
s_thr
->
start
();
s_thr
->
start
();
}
}
}
}
...
...
extensions/UNetUDP/UNetSender.h
View file @
705d6b82
...
@@ -86,8 +86,8 @@ class UNetSender
...
@@ -86,8 +86,8 @@ class UNetSender
std
::
string
myname
;
std
::
string
myname
;
int
sendpause
;
int
sendpause
;
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
UniSetTypes
::
uniset_rwmutex
pack_mutex
;
UniSetTypes
::
uniset_rwmutex
pack_mutex
;
UniSetUDP
::
UDPMessage
mypack
;
UniSetUDP
::
UDPMessage
mypack
;
DMap
dlist
;
DMap
dlist
;
...
...
extensions/include/UObject_SK.h
View file @
705d6b82
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// generate timestamp: 2014-01-2
4
+04:00
// generate timestamp: 2014-01-2
7
+04:00
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#ifndef UObject_SK_H_
#ifndef UObject_SK_H_
#define UObject_SK_H_
#define UObject_SK_H_
...
@@ -119,7 +119,7 @@ class UObject_SK:
...
@@ -119,7 +119,7 @@ class UObject_SK:
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
conf
->
getProp
(
confnode
,
name
);
}
inline
const
std
::
string
getProp
(
const
std
::
string
&
name
)
{
return
UniSetTypes
::
conf
->
getProp
(
confnode
,
name
);
}
int
smReadyTimeout
;
/*!< время ожидания готовности SM */
int
smReadyTimeout
;
/*!< время ожидания готовности SM */
bool
activated
;
UniSetTypes
::
mutex_atomic_t
activated
;
int
activateTimeout
;
/*!< время ожидания готовности UniSetObject к работе */
int
activateTimeout
;
/*!< время ожидания готовности UniSetObject к работе */
PassiveTimer
ptStartUpTimeout
;
/*!< время на блокировку обработки WatchDog, если недавно был StartUp */
PassiveTimer
ptStartUpTimeout
;
/*!< время на блокировку обработки WatchDog, если недавно был StartUp */
int
askPause
;
/*!< пауза между неудачными попытками заказать датчики */
int
askPause
;
/*!< пауза между неудачными попытками заказать датчики */
...
...
extensions/lib/UObject_SK.cc
View file @
705d6b82
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
ВСЕ ВАШИ ИЗМЕНЕНИЯ БУДУТ ПОТЕРЯНЫ.
*/
*/
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// generate timestamp: 2014-01-2
4
+04:00
// generate timestamp: 2014-01-2
7
+04:00
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include "Configuration.h"
#include "Configuration.h"
#include "Exceptions.h"
#include "Exceptions.h"
...
@@ -38,7 +38,7 @@ idHeartBeat(DefaultObjectId),
...
@@ -38,7 +38,7 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat
(
10
),
maxHeartBeat
(
10
),
confnode
(
0
),
confnode
(
0
),
smReadyTimeout
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
activated
(
0
),
askPause
(
2000
),
askPause
(
2000
),
end_private
(
false
)
end_private
(
false
)
...
@@ -73,7 +73,7 @@ idHeartBeat(DefaultObjectId),
...
@@ -73,7 +73,7 @@ idHeartBeat(DefaultObjectId),
maxHeartBeat
(
10
),
maxHeartBeat
(
10
),
confnode
(
cnode
),
confnode
(
cnode
),
smReadyTimeout
(
0
),
smReadyTimeout
(
0
),
activated
(
false
),
activated
(
0
),
askPause
(
conf
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
askPause
(
conf
->
getPIntProp
(
cnode
,
"askPause"
,
2000
)),
end_private
(
false
)
end_private
(
false
)
...
@@ -297,9 +297,9 @@ bool UObject_SK::activateObject()
...
@@ -297,9 +297,9 @@ bool UObject_SK::activateObject()
// пока не пройдёт инициализация датчиков
// пока не пройдёт инициализация датчиков
// см. sysCommand()
// см. sysCommand()
{
{
activated
=
false
;
activated
=
0
;
UniSetObject
::
activateObject
();
UniSetObject
::
activateObject
();
activated
=
true
;
activated
=
1
;
}
}
return
true
;
return
true
;
...
@@ -360,7 +360,7 @@ void UObject_SK::callback()
...
@@ -360,7 +360,7 @@ void UObject_SK::callback()
}
}
// обработка сообщений (таймеров и т.п.)
// обработка сообщений (таймеров и т.п.)
for
(
int
i
=
0
;
i
<
20
;
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
20
;
i
++
)
{
{
if
(
!
receiveMessage
(
msg
)
)
if
(
!
receiveMessage
(
msg
)
)
break
;
break
;
...
...
extensions/tests/SMemoryTest/Makefile.am
View file @
705d6b82
...
@@ -2,11 +2,11 @@ noinst_PROGRAMS = smemory-test
...
@@ -2,11 +2,11 @@ noinst_PROGRAMS = smemory-test
smemory_test_LDADD
=
$(top_builddir)
/lib/libUniSet.la
\
smemory_test_LDADD
=
$(top_builddir)
/lib/libUniSet.la
\
$(top_builddir)
/extensions/lib/libUniSetExtensions.la
\
$(top_builddir)
/extensions/lib/libUniSetExtensions.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSetSharedMemory.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSetSharedMemory.la
\
$(SIGC_LIBS)
$(SIGC_LIBS)
$(COMCPP_LIBS)
smemory_test_CPPFLAGS
=
-I
$(top_builddir)
/include
\
smemory_test_CPPFLAGS
=
-I
$(top_builddir)
/include
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/include
\
-I
$(top_builddir)
/extensions/SharedMemory
\
-I
$(top_builddir)
/extensions/SharedMemory
\
$(SIGC_CFLAGS)
$(SIGC_CFLAGS)
$(COMCPP_CFLAGS)
smemory_test_SOURCES
=
TestProc_SK.cc TestProc.cc smemory-test.cc
smemory_test_SOURCES
=
TestProc_SK.cc TestProc.cc smemory-test.cc
TestProc_SK.cc
:
testproc.src.xml
TestProc_SK.cc
:
testproc.src.xml
...
...
include/Mutex.h
View file @
705d6b82
...
@@ -43,7 +43,7 @@ namespace UniSetTypes
...
@@ -43,7 +43,7 @@ namespace UniSetTypes
{
{
public
:
public
:
uniset_mutex
();
uniset_mutex
();
uniset_mutex
(
std
::
string
name
);
uniset_mutex
(
const
std
::
string
&
name
);
~
uniset_mutex
();
~
uniset_mutex
();
bool
isRelease
();
bool
isRelease
();
...
@@ -57,8 +57,8 @@ namespace UniSetTypes
...
@@ -57,8 +57,8 @@ namespace UniSetTypes
private
:
private
:
friend
class
uniset_mutex_lock
;
friend
class
uniset_mutex_lock
;
uniset_mutex
(
const
uniset_mutex
&
r
);
uniset_mutex
(
const
uniset_mutex
&
r
);
const
uniset_mutex
&
operator
=
(
const
uniset_mutex
&
r
);
const
uniset_mutex
&
operator
=
(
const
uniset_mutex
&
r
);
omni_condition
*
cnd
;
omni_condition
*
cnd
;
std
::
string
nm
;
std
::
string
nm
;
omni_semaphore
sem
;
omni_semaphore
sem
;
...
@@ -85,7 +85,7 @@ namespace UniSetTypes
...
@@ -85,7 +85,7 @@ namespace UniSetTypes
bool
lock_ok
();
bool
lock_ok
();
private
:
private
:
uniset_mutex
*
mutex
;
uniset_mutex
*
mutex
;
mutex_atomic_t
mlock
;
mutex_atomic_t
mlock
;
uniset_mutex_lock
(
const
uniset_mutex_lock
&
);
uniset_mutex_lock
(
const
uniset_mutex_lock
&
);
uniset_mutex_lock
&
operator
=
(
const
uniset_mutex_lock
&
);
uniset_mutex_lock
&
operator
=
(
const
uniset_mutex_lock
&
);
...
@@ -110,7 +110,7 @@ namespace UniSetTypes
...
@@ -110,7 +110,7 @@ namespace UniSetTypes
bool
tryrlock
();
bool
tryrlock
();
bool
trywrlock
();
bool
trywrlock
();
uniset_rwmutex
(
const
uniset_rwmutex
&
r
);
uniset_rwmutex
(
const
uniset_rwmutex
&
r
);
const
uniset_rwmutex
&
operator
=
(
const
uniset_rwmutex
&
r
);
const
uniset_rwmutex
&
operator
=
(
const
uniset_rwmutex
&
r
);
inline
std
::
string
name
(){
return
nm
;
}
inline
std
::
string
name
(){
return
nm
;
}
...
@@ -121,7 +121,7 @@ namespace UniSetTypes
...
@@ -121,7 +121,7 @@ namespace UniSetTypes
friend
class
uniset_rwmutex_lock
;
friend
class
uniset_rwmutex_lock
;
ost
::
ThreadLock
m
;
ost
::
ThreadLock
m
;
ost
::
AtomicCounter
wr_wait
;
ost
::
AtomicCounter
wr_wait
;
static
int
num
;
static
ost
::
AtomicCounter
num
;
};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
uniset_rwmutex
&
m
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
uniset_rwmutex
&
m
);
...
...
include/PassiveTimer.h
View file @
705d6b82
...
@@ -127,7 +127,7 @@ class ThrPassiveTimer:
...
@@ -127,7 +127,7 @@ class ThrPassiveTimer:
public
PassiveTimer
public
PassiveTimer
{
{
public
:
public
:
ThrPassiveTimer
();
ThrPassiveTimer
();
~
ThrPassiveTimer
();
~
ThrPassiveTimer
();
...
@@ -136,7 +136,7 @@ class ThrPassiveTimer:
...
@@ -136,7 +136,7 @@ class ThrPassiveTimer:
protected
:
protected
:
bool
isTerminated
();
bool
isTerminated
();
void
setTerminated
(
bool
set
);
void
setTerminated
(
bool
set
);
private
:
private
:
bool
terminated
;
bool
terminated
;
omni_mutex
*
tmutex
;
omni_mutex
*
tmutex
;
...
...
src/Communications/Modbus/ModbusRTUMaster.cc
View file @
705d6b82
...
@@ -77,7 +77,7 @@ ComPort::Speed ModbusRTUMaster::getSpeed()
...
@@ -77,7 +77,7 @@ ComPort::Speed ModbusRTUMaster::getSpeed()
{
{
if
(
port
==
NULL
)
if
(
port
==
NULL
)
return
ComPort
::
ComSpeed0
;
return
ComPort
::
ComSpeed0
;
return
port
->
getSpeed
();
return
port
->
getSpeed
();
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
@@ -103,7 +103,7 @@ int ModbusRTUMaster::getTimeout()
...
@@ -103,7 +103,7 @@ int ModbusRTUMaster::getTimeout()
{
{
if
(
port
==
NULL
)
if
(
port
==
NULL
)
return
0
;
return
0
;
return
port
->
getTimeout
();
return
port
->
getTimeout
();
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
...
...
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
705d6b82
...
@@ -84,7 +84,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
...
@@ -84,7 +84,7 @@ mbErrCode ModbusTCPMaster::query( ModbusAddr addr, ModbusMessage& msg,
if
(
nTransaction
>=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
()
)
if
(
nTransaction
>=
numeric_limits
<
ModbusRTU
::
ModbusData
>::
max
()
)
nTransaction
=
0
;
nTransaction
=
0
;
ModbusTCP
::
MBAPHeader
mh
;
ModbusTCP
::
MBAPHeader
mh
;
mh
.
tID
=
++
nTransaction
;
mh
.
tID
=
++
nTransaction
;
mh
.
pID
=
0
;
mh
.
pID
=
0
;
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
705d6b82
...
@@ -106,9 +106,9 @@ using namespace UniSetTypes;
...
@@ -106,9 +106,9 @@ using namespace UniSetTypes;
UniSetTypes
::
IDList
::
IDList
()
:
UniSetTypes
::
IDList
::
IDList
()
:
node
(
UniSetTypes
::
conf
->
getLocalNode
())
node
(
UniSetTypes
::
conf
->
getLocalNode
())
{
{
}
}
UniSetTypes
::
IDList
::~
IDList
()
UniSetTypes
::
IDList
::~
IDList
()
{
{
}
}
...
@@ -120,11 +120,10 @@ using namespace UniSetTypes;
...
@@ -120,11 +120,10 @@ using namespace UniSetTypes;
if
(
(
*
it
)
==
id
)
if
(
(
*
it
)
==
id
)
return
;
return
;
}
}
lst
.
push_back
(
id
);
lst
.
push_back
(
id
);
}
}
void
UniSetTypes
::
IDList
::
del
(
ObjectId
id
)
void
UniSetTypes
::
IDList
::
del
(
ObjectId
id
)
{
{
for
(
list
<
ObjectId
>::
iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
for
(
list
<
ObjectId
>::
iterator
it
=
lst
.
begin
();
it
!=
lst
.
end
();
++
it
)
...
...
src/Various/Mutex.cc
View file @
705d6b82
...
@@ -41,8 +41,8 @@ uniset_mutex::uniset_mutex():
...
@@ -41,8 +41,8 @@ uniset_mutex::uniset_mutex():
cnd
=
new
omni_condition
(
&
mtx
);
cnd
=
new
omni_condition
(
&
mtx
);
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
uniset_mutex
::
uniset_mutex
(
string
name
)
:
uniset_mutex
::
uniset_mutex
(
const
string
&
name
)
:
cnd
(
0
),
cnd
(
0
),
nm
(
name
),
nm
(
name
),
locked
(
0
)
locked
(
0
)
{
{
...
@@ -63,7 +63,6 @@ void uniset_mutex::lock()
...
@@ -63,7 +63,6 @@ void uniset_mutex::lock()
{
{
sem
.
wait
();
sem
.
wait
();
locked
=
1
;
locked
=
1
;
MUTEX_DEBUG
(
cerr
<<
nm
<<
" Locked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" Locked.."
<<
endl
;)
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -154,7 +153,7 @@ wr_wait(0)
...
@@ -154,7 +153,7 @@ wr_wait(0)
}
}
int
uniset_rwmutex
::
num
=
0
;
ost
::
AtomicCounter
uniset_rwmutex
::
num
=
0
;
uniset_rwmutex
::
uniset_rwmutex
()
:
uniset_rwmutex
::
uniset_rwmutex
()
:
nm
(
""
),
nm
(
""
),
...
@@ -181,7 +180,7 @@ const uniset_rwmutex &uniset_rwmutex::operator=( const uniset_rwmutex& r )
...
@@ -181,7 +180,7 @@ const uniset_rwmutex &uniset_rwmutex::operator=( const uniset_rwmutex& r )
nm
=
s
.
str
();
nm
=
s
.
str
();
unlock
();
unlock
();
}
}
return
*
this
;
return
*
this
;
}
}
...
@@ -193,25 +192,25 @@ nm(r.nm)
...
@@ -193,25 +192,25 @@ nm(r.nm)
void
uniset_rwmutex
::
lock
()
void
uniset_rwmutex
::
lock
()
{
{
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare Locked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare Locked.."
<<
endl
;)
wr_wait
+=
1
;
wr_wait
+=
1
;
m
.
writeLock
();
m
.
writeLock
();
wr_wait
-=
1
;
wr_wait
-=
1
;
MUTEX_DEBUG
(
cerr
<<
nm
<<
" Locked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" Locked.."
<<
endl
;)
}
}
void
uniset_rwmutex
::
wrlock
()
void
uniset_rwmutex
::
wrlock
()
{
{
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare WRLocked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare WRLocked.."
<<
endl
;)
wr_wait
+=
1
;
wr_wait
+=
1
;
m
.
writeLock
();
m
.
writeLock
();
wr_wait
-=
1
;
wr_wait
-=
1
;
MUTEX_DEBUG
(
cerr
<<
nm
<<
" WRLocked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" WRLocked.."
<<
endl
;)
}
}
void
uniset_rwmutex
::
rlock
()
void
uniset_rwmutex
::
rlock
()
{
{
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare RLocked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" prepare RLocked.."
<<
endl
;)
while
(
wr_wait
>
0
)
while
(
wr_wait
)
msleep
(
2
);
msleep
(
2
);
m
.
readLock
();
m
.
readLock
();
MUTEX_DEBUG
(
cerr
<<
nm
<<
" RLocked.."
<<
endl
;)
MUTEX_DEBUG
(
cerr
<<
nm
<<
" RLocked.."
<<
endl
;)
...
...
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