Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
8c1d5228
Commit
8c1d5228
authored
6 years ago
by
Mengmeng Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support custom executor in execution_queue
parent
29b74413
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
1 deletion
+21
-1
execution_queue.cpp
src/bthread/execution_queue.cpp
+7
-0
execution_queue.h
src/bthread/execution_queue.h
+13
-0
execution_queue_inl.h
src/bthread/execution_queue_inl.h
+1
-1
No files found.
src/bthread/execution_queue.cpp
View file @
8c1d5228
...
...
@@ -101,6 +101,7 @@ void ExecutionQueueBase::start_execute(TaskNode* node) {
}
}
if
(
nullptr
==
_options
.
executor
)
{
bthread_t
tid
;
// We start the execution thread in background instead of foreground as
// we can't determine whether the code after execute() is urgent (like
...
...
@@ -111,6 +112,12 @@ void ExecutionQueueBase::start_execute(TaskNode* node) {
PLOG
(
FATAL
)
<<
"Fail to start bthread"
;
_execute_tasks
(
node
);
}
}
else
{
if
(
_options
.
executor
->
submit
(
_execute_tasks
,
node
)
!=
0
)
{
PLOG
(
FATAL
)
<<
"Fail to submit task"
;
_execute_tasks
(
node
);
}
}
}
void
*
ExecutionQueueBase
::
_execute_tasks
(
void
*
arg
)
{
...
...
This diff is collapsed.
Click to expand it.
src/bthread/execution_queue.h
View file @
8c1d5228
...
...
@@ -128,11 +128,24 @@ const static TaskOptions TASK_OPTIONS_NORMAL = TaskOptions(false, false);
const
static
TaskOptions
TASK_OPTIONS_URGENT
=
TaskOptions
(
true
,
false
);
const
static
TaskOptions
TASK_OPTIONS_INPLACE
=
TaskOptions
(
false
,
true
);
class
Executor
{
public
:
virtual
~
Executor
()
{}
// Return 0 on success.
virtual
int
submit
(
void
*
(
*
fn
)(
void
*
),
void
*
args
)
=
0
;
};
struct
ExecutionQueueOptions
{
ExecutionQueueOptions
();
// Attribute of the bthread which execute runs on
// default: BTHREAD_ATTR_NORMAL
bthread_attr_t
bthread_attr
;
// Executor that tasks run on. bthread will be used when executor = NULL.
// Note that TaskOptions.in_place_if_possible = false will not work, if implementation of
// Executor is in-place(synchronous).
Executor
*
executor
;
};
// Start a ExecutionQueue. If |options| is NULL, the queue will be created with
...
...
This diff is collapsed.
Click to expand it.
src/bthread/execution_queue_inl.h
View file @
8c1d5228
...
...
@@ -317,7 +317,7 @@ public:
};
inline
ExecutionQueueOptions
::
ExecutionQueueOptions
()
:
bthread_attr
(
BTHREAD_ATTR_NORMAL
)
:
bthread_attr
(
BTHREAD_ATTR_NORMAL
)
,
executor
(
NULL
)
{}
template
<
typename
T
>
...
...
This diff is collapsed.
Click to expand it.
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