This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
valgrind: use static-allocated array to store mapping from task_code to task_spec #173
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0a8c16a
valgrind: use static-allocated array to store mapping from task_code …
84dba72
fix valgrind warnings for json_helper
60cacb5
Merge branch 'master' into dev3
qinzuoyan 32a1716
fix edge condition of task spec store
40c69a3
Merge branch 'master' into dev3
a8fba08
make 512 a constant (TASK_SPEC_STORE_CAPACITY)
545bfd8
Merge branch 'dev3' of https://github.com/neverchanje/rdsn into dev3
b35801d
Merge branch 'master' into dev3
bacbed9
Merge branch 'master' into dev3
qinzuoyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,24 +34,23 @@ | |
*/ | ||
|
||
#include <dsn/tool-api/task_spec.h> | ||
#include <dsn/utility/singleton.h> | ||
#include <dsn/perf_counter/perf_counter.h> | ||
#include <dsn/tool-api/command_manager.h> | ||
#include <dsn/tool-api/threadpool_spec.h> | ||
#include <sstream> | ||
#include <vector> | ||
#include <thread> | ||
#include <dsn/utility/smart_pointers.h> | ||
|
||
namespace dsn { | ||
|
||
// A sequential storage maps task_code to task_spec. | ||
static std::array<std::unique_ptr<task_spec>, 512> s_task_spec_store; | ||
|
||
void task_spec::register_task_code(task_code code, | ||
dsn_task_type_t type, | ||
dsn_task_priority_t pri, | ||
dsn::threadpool_code pool) | ||
{ | ||
if (!dsn::utils::singleton_vector_store<task_spec *, nullptr>::instance().contains(code)) { | ||
task_spec *spec = new task_spec(code, code.to_string(), type, pri, pool); | ||
dsn::utils::singleton_vector_store<task_spec *, nullptr>::instance().put(code, spec); | ||
if (!s_task_spec_store[code]) { | ||
s_task_spec_store[code] = make_unique<task_spec>(code, code.to_string(), type, pri, pool); | ||
auto &spec = s_task_spec_store[code]; | ||
|
||
if (type == TASK_TYPE_RPC_REQUEST) { | ||
std::string ack_name = std::string(code.to_string()) + std::string("_ACK"); | ||
|
@@ -112,10 +111,7 @@ void task_spec::register_storage_task_code(task_code code, | |
spec->rpc_request_is_write_idempotent = is_idempotent; | ||
} | ||
|
||
task_spec *task_spec::get(int code) | ||
{ | ||
return dsn::utils::singleton_vector_store<task_spec *, nullptr>::instance().get(code); | ||
} | ||
task_spec *task_spec::get(int code) { return s_task_spec_store[code].get(); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该为:
|
||
|
||
task_spec::task_spec(int code, | ||
const char *name, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加上: dassert(code < 512, "code = %d", code);