Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
9c256980
Commit
9c256980
authored
9 years ago
by
Sree Kuchibhotla
Browse files
Options
Downloads
Plain Diff
Merge pull request #4192 from ctiller/stupid-threads
Two argument variant for grpc::thread
parents
ceb7318d
52a2ebad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/grpc++/impl/thd_no_cxx11.h
+23
-0
23 additions, 0 deletions
include/grpc++/impl/thd_no_cxx11.h
with
23 additions
and
0 deletions
include/grpc++/impl/thd_no_cxx11.h
+
23
−
0
View file @
9c256980
...
@@ -46,10 +46,21 @@ class thread {
...
@@ -46,10 +46,21 @@ class thread {
joined_
=
false
;
joined_
=
false
;
start
();
start
();
}
}
template
<
class
T
,
class
U
>
thread
(
void
(
T
::*
fptr
)(
U
arg
),
T
*
obj
,
U
arg
)
{
func_
=
new
thread_function_arg
<
T
,
U
>
(
fptr
,
obj
,
arg
);
joined_
=
false
;
start
();
}
~
thread
()
{
~
thread
()
{
if
(
!
joined_
)
std
::
terminate
();
if
(
!
joined_
)
std
::
terminate
();
delete
func_
;
delete
func_
;
}
}
thread
(
thread
&&
other
)
:
func_
(
other
.
func_
),
thd_
(
other
.
thd_
),
joined_
(
other
.
joined_
)
{
other
.
joined_
=
true
;
other
.
func_
=
NULL
;
}
void
join
()
{
void
join
()
{
gpr_thd_join
(
thd_
);
gpr_thd_join
(
thd_
);
joined_
=
true
;
joined_
=
true
;
...
@@ -80,6 +91,18 @@ class thread {
...
@@ -80,6 +91,18 @@ class thread {
void
(
T
::*
fptr_
)();
void
(
T
::*
fptr_
)();
T
*
obj_
;
T
*
obj_
;
};
};
template
<
class
T
,
class
U
>
class
thread_function_arg
:
public
thread_function_base
{
public:
thread_function_arg
(
void
(
T
::*
fptr
)(
U
arg
),
T
*
obj
,
U
arg
)
:
fptr_
(
fptr
),
obj_
(
obj
),
arg_
(
arg
)
{}
virtual
void
call
()
{
(
obj_
->*
fptr_
)(
arg_
);
}
private
:
void
(
T
::*
fptr_
)(
U
arg
);
T
*
obj_
;
U
arg_
;
};
thread_function_base
*
func_
;
thread_function_base
*
func_
;
gpr_thd_id
thd_
;
gpr_thd_id
thd_
;
bool
joined_
;
bool
joined_
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment