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
1ccb0aa5
Commit
1ccb0aa5
authored
Dec 13, 2013
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(Thread): рефакторинг класса ThreadCreator
parent
f2402ac2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
5 deletions
+36
-5
ThreadCreator.h
include/ThreadCreator.h
+33
-2
ObjectsActivator.cc
src/ObjectRepository/ObjectsActivator.cc
+1
-1
UniSetObject.cc
src/ObjectRepository/UniSetObject.cc
+1
-1
SystemGuard.cc
src/Various/SystemGuard.cc
+1
-1
No files found.
include/ThreadCreator.h
View file @
1ccb0aa5
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#define ThreadCreator_h_
#define ThreadCreator_h_
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
#include <cc++/thread.h>
#include <cc++/thread.h>
#include <sys/resource.h>
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
/*! \class ThreadCreator
/*! \class ThreadCreator
* Шаблон для создания потоков с указанием функции вызова.
* Шаблон для создания потоков с указанием функции вызова.
...
@@ -93,11 +94,24 @@ class ThreadCreator:
...
@@ -93,11 +94,24 @@ class ThreadCreator:
ThreadCreator
(
ThreadMaster
*
m
,
Action
a
);
ThreadCreator
(
ThreadMaster
*
m
,
Action
a
);
~
ThreadCreator
();
~
ThreadCreator
();
inline
pid_t
getTID
(){
return
pid
;
}
/*! \return 0 - sucess */
int
setPriority
(
int
prior
);
/*! \return < 0 - fail */
int
getPriority
();
void
stop
();
void
stop
();
inline
void
setPriority
(
int
ptior
)
inline
void
setName
(
const
std
::
string
&
name
)
{
ost
::
PosixThread
::
setName
(
name
.
c_str
()
);
}
inline
void
setName
(
const
char
*
name
)
{
{
#warning ThreadCreator::setPriority NOT REALIZED YET
ost
::
PosixThread
::
setName
(
name
);
}
}
inline
void
setCancel
(
ost
::
Thread
::
Cancel
mode
)
inline
void
setCancel
(
ost
::
Thread
::
Cancel
mode
)
...
@@ -133,6 +147,8 @@ class ThreadCreator:
...
@@ -133,6 +147,8 @@ class ThreadCreator:
private
:
private
:
ThreadCreator
();
ThreadCreator
();
pid_t
pid
;
ThreadMaster
*
m
;
ThreadMaster
*
m
;
Action
act
;
Action
act
;
...
@@ -147,6 +163,7 @@ class ThreadCreator:
...
@@ -147,6 +163,7 @@ class ThreadCreator:
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
template
<
class
ThreadMaster
>
template
<
class
ThreadMaster
>
ThreadCreator
<
ThreadMaster
>::
ThreadCreator
(
ThreadMaster
*
m
,
Action
a
)
:
ThreadCreator
<
ThreadMaster
>::
ThreadCreator
(
ThreadMaster
*
m
,
Action
a
)
:
pid
(
-
1
),
m
(
m
),
m
(
m
),
act
(
a
),
act
(
a
),
finm
(
0
),
finm
(
0
),
...
@@ -159,6 +176,7 @@ ThreadCreator<ThreadMaster>::ThreadCreator( ThreadMaster* m, Action a ):
...
@@ -159,6 +176,7 @@ ThreadCreator<ThreadMaster>::ThreadCreator( ThreadMaster* m, Action a ):
template
<
class
ThreadMaster
>
template
<
class
ThreadMaster
>
void
ThreadCreator
<
ThreadMaster
>::
run
()
void
ThreadCreator
<
ThreadMaster
>::
run
()
{
{
pid
=
getpid
();
if
(
m
)
if
(
m
)
(
m
->*
act
)();
(
m
->*
act
)();
// PosixThread::stop()
// PosixThread::stop()
...
@@ -172,6 +190,7 @@ void ThreadCreator<ThreadMaster>::stop()
...
@@ -172,6 +190,7 @@ void ThreadCreator<ThreadMaster>::stop()
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
template
<
class
ThreadMaster
>
template
<
class
ThreadMaster
>
ThreadCreator
<
ThreadMaster
>::
ThreadCreator
()
:
ThreadCreator
<
ThreadMaster
>::
ThreadCreator
()
:
pid
(
-
1
),
m
(
0
),
m
(
0
),
act
(
0
),
act
(
0
),
finm
(
0
),
finm
(
0
),
...
@@ -186,4 +205,16 @@ ThreadCreator<ThreadMaster>::~ThreadCreator()
...
@@ -186,4 +205,16 @@ ThreadCreator<ThreadMaster>::~ThreadCreator()
{
{
}
}
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
template
<
class
ThreadMaster
>
int
ThreadCreator
<
ThreadMaster
>::
setPriority
(
int
prior
)
{
return
setpriority
(
PRIO_PROCESS
,
pid
,
prior
);
}
//----------------------------------------------------------------------------------------
template
<
class
ThreadMaster
>
int
ThreadCreator
<
ThreadMaster
>::
getPriority
()
{
return
getpriority
(
PRIO_PROCESS
,
pid
);
}
//----------------------------------------------------------------------------------------
#endif // ThreadCreator_h_
#endif // ThreadCreator_h_
src/ObjectRepository/ObjectsActivator.cc
View file @
1ccb0aa5
...
@@ -262,7 +262,7 @@ void ObjectsActivator::work()
...
@@ -262,7 +262,7 @@ void ObjectsActivator::work()
try
try
{
{
if
(
orbthr
)
if
(
orbthr
)
thpid
=
orbthr
->
get
Id
();
thpid
=
orbthr
->
get
TID
();
else
else
thpid
=
getpid
();
thpid
=
getpid
();
...
...
src/ObjectRepository/UniSetObject.cc
View file @
1ccb0aa5
...
@@ -874,7 +874,7 @@ void UniSetObject::work()
...
@@ -874,7 +874,7 @@ void UniSetObject::work()
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
if
(
unideb
.
debugging
(
Debug
::
INFO
)
)
unideb
[
Debug
::
INFO
]
<<
myname
<<
": thread processing messages run..."
<<
endl
;
unideb
[
Debug
::
INFO
]
<<
myname
<<
": thread processing messages run..."
<<
endl
;
if
(
thr
)
if
(
thr
)
msgpid
=
thr
->
get
Id
();
msgpid
=
thr
->
get
TID
();
while
(
isActive
()
)
while
(
isActive
()
)
{
{
callback
();
callback
();
...
...
src/Various/SystemGuard.cc
View file @
1ccb0aa5
...
@@ -347,7 +347,7 @@ SimpleInfo* SystemGuard::getInfo()
...
@@ -347,7 +347,7 @@ SimpleInfo* SystemGuard::getInfo()
SimpleInfo_var
si
=
ObjectsManager
::
getInfo
();
SimpleInfo_var
si
=
ObjectsManager
::
getInfo
();
info
<<
si
->
info
;
info
<<
si
->
info
;
if
(
thr
)
if
(
thr
)
info
<<
"
\t
exTID= "
<<
thr
->
get
Id
();
info
<<
"
\t
exTID= "
<<
thr
->
get
TID
();
else
else
info
<<
"
\t
expid= "
<<
expid
;
info
<<
"
\t
expid= "
<<
expid
;
...
...
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