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
5264b40b
Commit
5264b40b
authored
May 30, 2017
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(CommonEventLoop): переделал процесс старта (evrun)
parent
0a13cee8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
28 deletions
+42
-28
logserver.cc
Utilities/ULog/logserver.cc
+3
-0
libuniset2.spec
conf/libuniset2.spec
+3
-0
UNetExchange.cc
extensions/UNetUDP/UNetExchange.cc
+1
-1
CommonEventLoop.h
include/CommonEventLoop.h
+8
-2
CommonEventLoop.cc
src/Processes/CommonEventLoop.cc
+27
-25
No files found.
Utilities/ULog/logserver.cc
View file @
5264b40b
...
@@ -182,7 +182,10 @@ int main( int argc, char** argv )
...
@@ -182,7 +182,10 @@ int main( int argc, char** argv )
if
(
!
ls
.
isRunning
()
)
if
(
!
ls
.
isRunning
()
)
{
cerr
<<
"LOG SERVER NOT RUNNING!!"
<<
endl
;
cerr
<<
"LOG SERVER NOT RUNNING!!"
<<
endl
;
return
1
;
}
unsigned
int
i
=
0
;
unsigned
int
i
=
0
;
...
...
conf/libuniset2.spec
View file @
5264b40b
...
@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la
...
@@ -511,6 +511,9 @@ rm -f %buildroot%_libdir/*.la
* Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1
* Tue Sep 12 2017 Alexei Takaseev <taf@altlinux.org> 2.6-alt19.1
- Rebuild with poco 1.7.9
- Rebuild with poco 1.7.9
# * Tue May 30 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt23.1
# - CommonEventLoop refactring start process
# * Mon May 29 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt23
# * Mon May 29 2017 Pavel Vainerman <pv@altlinux.ru> 2.6-alt23
# - (Configuration): add getStartapIgnoreTimeout()
# - (Configuration): add getStartapIgnoreTimeout()
# - minor fixes
# - minor fixes
...
...
extensions/UNetUDP/UNetExchange.cc
View file @
5264b40b
...
@@ -76,7 +76,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
...
@@ -76,7 +76,7 @@ UNetExchange::UNetExchange(uniset::ObjectId objId, uniset::ObjectId shmId, const
int
recvTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recvTimeout"
),
5000
);
int
recvTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recv-timeout"
,
it
.
getProp
(
"recvTimeout"
),
5000
);
int
prepareTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-prepare-time"
,
it
.
getProp
(
"prepareTime"
),
2000
);
int
prepareTime
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-prepare-time"
,
it
.
getProp
(
"prepareTime"
),
2000
);
int
evrunTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-evrun-timeout"
,
it
.
getProp
(
"evrunTimeout"
),
4
0000
);
int
evrunTimeout
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-evrun-timeout"
,
it
.
getProp
(
"evrunTimeout"
),
6
0000
);
int
recvpause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recvpause"
,
it
.
getProp
(
"recvpause"
),
10
);
int
recvpause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-recvpause"
,
it
.
getProp
(
"recvpause"
),
10
);
int
sendpause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sendpause"
,
it
.
getProp
(
"sendpause"
),
100
);
int
sendpause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-sendpause"
,
it
.
getProp
(
"sendpause"
),
100
);
int
updatepause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-updatepause"
,
it
.
getProp
(
"updatepause"
),
100
);
int
updatepause
=
conf
->
getArgPInt
(
"--"
+
prefix
+
"-updatepause"
,
it
.
getProp
(
"updatepause"
),
100
);
...
...
include/CommonEventLoop.h
View file @
5264b40b
...
@@ -67,7 +67,7 @@ namespace uniset
...
@@ -67,7 +67,7 @@ namespace uniset
* Даже если thread = false, но wather не сможет быть "активирован" функция вернёт управление
* Даже если thread = false, но wather не сможет быть "активирован" функция вернёт управление
* с return false.
* с return false.
*/
*/
bool
evrun
(
EvWatcher
*
w
,
bool
thread
=
true
,
size_t
waitPrepareTimeout_msec
=
5
000
);
bool
evrun
(
EvWatcher
*
w
,
bool
thread
=
true
,
size_t
waitPrepareTimeout_msec
=
60
000
);
/*! \return TRUE - если это был последний EvWatcher и loop остановлен */
/*! \return TRUE - если это был последний EvWatcher и loop остановлен */
bool
evstop
(
EvWatcher
*
w
);
bool
evstop
(
EvWatcher
*
w
);
...
@@ -86,9 +86,10 @@ namespace uniset
...
@@ -86,9 +86,10 @@ namespace uniset
void
onStop
(
ev
::
async
&
w
,
int
revents
)
noexcept
;
void
onStop
(
ev
::
async
&
w
,
int
revents
)
noexcept
;
void
onPrepare
(
ev
::
async
&
w
,
int
revents
)
noexcept
;
void
onPrepare
(
ev
::
async
&
w
,
int
revents
)
noexcept
;
void
defaultLoop
(
std
::
promise
<
bool
>&
runOK
)
noexcept
;
void
defaultLoop
()
noexcept
;
bool
runDefaultLoop
(
size_t
waitTimeout_msec
);
bool
runDefaultLoop
(
size_t
waitTimeout_msec
);
bool
activateWatcher
(
EvWatcher
*
w
,
size_t
waitTimeout_msec
);
bool
activateWatcher
(
EvWatcher
*
w
,
size_t
waitTimeout_msec
);
void
onLoopOK
(
ev
::
timer
&
t
,
int
revents
)
noexcept
;
std
::
atomic_bool
cancelled
=
{
false
};
std
::
atomic_bool
cancelled
=
{
false
};
std
::
atomic_bool
isrunning
=
{
false
};
std
::
atomic_bool
isrunning
=
{
false
};
...
@@ -118,6 +119,11 @@ namespace uniset
...
@@ -118,6 +119,11 @@ namespace uniset
std
::
queue
<
WatcherInfo
>
wactlist
;
std
::
queue
<
WatcherInfo
>
wactlist
;
std
::
mutex
wact_mutex
;
std
::
mutex
wact_mutex
;
ev
::
async
evprep
;
ev
::
async
evprep
;
std
::
mutex
looprunOK_mutex
;
std
::
condition_variable
looprunOK_event
;
std
::
atomic_bool
looprunOK_state
;
ev
::
timer
evruntimer
;
};
};
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
}
// end of uniset namespace
}
// end of uniset namespace
...
...
src/Processes/CommonEventLoop.cc
View file @
5264b40b
...
@@ -15,6 +15,9 @@ namespace uniset
...
@@ -15,6 +15,9 @@ namespace uniset
evprep
.
set
(
loop
);
evprep
.
set
(
loop
);
evprep
.
set
<
CommonEventLoop
,
&
CommonEventLoop
::
onPrepare
>
(
this
);
evprep
.
set
<
CommonEventLoop
,
&
CommonEventLoop
::
onPrepare
>
(
this
);
evruntimer
.
set
(
loop
);
evruntimer
.
set
<
CommonEventLoop
,
&
CommonEventLoop
::
onLoopOK
>
(
this
);
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
CommonEventLoop
::~
CommonEventLoop
()
CommonEventLoop
::~
CommonEventLoop
()
...
@@ -38,31 +41,15 @@ namespace uniset
...
@@ -38,31 +41,15 @@ namespace uniset
if
(
thr
)
if
(
thr
)
return
true
;
return
true
;
bool
defaultLoopOK
=
true
;
thr
=
make_shared
<
std
::
thread
>
(
[
&
]
{
CommonEventLoop
::
defaultLoop
();
}
);
std
::
promise
<
bool
>
pRun
;
auto
runOK
=
pRun
.
get_future
();
thr
=
make_shared
<
std
::
thread
>
(
[
&
pRun
,
this
]
{
CommonEventLoop
::
defaultLoop
(
pRun
);
}
);
// ожидание старта потока
while
(
true
)
{
auto
status
=
runOK
.
wait_for
(
std
::
chrono
::
milliseconds
(
waitTimeout_msec
));
if
(
status
==
future_status
::
timeout
)
{
defaultLoopOK
=
false
;
break
;
}
if
(
status
==
future_status
::
ready
)
std
::
unique_lock
<
std
::
mutex
>
lock2
(
looprunOK_mutex
);
looprunOK_event
.
wait_for
(
lock2
,
std
::
chrono
::
milliseconds
(
waitTimeout_msec
),
[
&
]()
{
{
defaultLoopOK
=
runOK
.
get
();
return
(
looprunOK_state
==
true
);
break
;
}
);
}
}
return
defaultLoopOK
;
return
looprunOK_state
;
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
bool
CommonEventLoop
::
activateWatcher
(
EvWatcher
*
w
,
size_t
waitTimeout_msec
)
bool
CommonEventLoop
::
activateWatcher
(
EvWatcher
*
w
,
size_t
waitTimeout_msec
)
...
@@ -78,6 +65,9 @@ namespace uniset
...
@@ -78,6 +65,9 @@ namespace uniset
bool
ret
=
true
;
bool
ret
=
true
;
if
(
!
evprep
.
is_active
()
)
evprep
.
start
();
// посылаем сигнал для обработки
// посылаем сигнал для обработки
evprep
.
send
();
// будим default loop
evprep
.
send
();
// будим default loop
...
@@ -101,6 +91,16 @@ namespace uniset
...
@@ -101,6 +91,16 @@ namespace uniset
return
ret
;
return
ret
;
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
void
CommonEventLoop
::
onLoopOK
(
ev
::
timer
&
t
,
int
revents
)
noexcept
{
if
(
EV_ERROR
&
revents
)
return
;
looprunOK_state
=
true
;
looprunOK_event
.
notify_all
();
t
.
stop
();
}
// ---------------------------------------------------------------------------
bool
CommonEventLoop
::
evrun
(
EvWatcher
*
w
,
bool
thread
,
size_t
waitTimeout_msec
)
bool
CommonEventLoop
::
evrun
(
EvWatcher
*
w
,
bool
thread
,
size_t
waitTimeout_msec
)
{
{
if
(
w
==
nullptr
)
if
(
w
==
nullptr
)
...
@@ -249,14 +249,16 @@ namespace uniset
...
@@ -249,14 +249,16 @@ namespace uniset
}
}
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
void
CommonEventLoop
::
defaultLoop
(
std
::
promise
<
bool
>&
runOK
)
noexcept
void
CommonEventLoop
::
defaultLoop
()
noexcept
{
{
evterm
.
start
();
evterm
.
start
();
evprep
.
start
();
evprep
.
start
();
isrunning
=
true
;
// делаем очень маленькое время старта
// т.к. нам надо просто зафиксировать, что loop начал работать
evruntimer
.
start
(
0
,
0.001
);
runOK
.
set_value
(
true
)
;
isrunning
=
true
;
while
(
!
cancelled
)
while
(
!
cancelled
)
{
{
...
...
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