updates from comments
Former-commit-id: 852885f09e7df1d9570408546baffa8545707335
This commit is contained in:
parent
3239f678d5
commit
26aa8f0828
@ -1184,7 +1184,7 @@ void scanGenericCommand(client *c, robj_roptr o, unsigned long cursor) {
|
||||
{
|
||||
// Do an async version
|
||||
if (c->asyncCommand(
|
||||
[c, keys, pat, type, cursor, count, use_pattern] (const redisDbPersistentDataSnapshot *snapshot, std::vector<robj_sharedptr>) {
|
||||
[c, keys, pat, type, cursor, count, use_pattern] (const redisDbPersistentDataSnapshot *snapshot, const std::vector<robj_sharedptr> &) {
|
||||
sds patCopy = pat ? sdsdup(pat) : nullptr;
|
||||
sds typeCopy = type ? sdsdup(type) : nullptr;
|
||||
auto cursorResult = snapshot->scan_threadsafe(cursor, count, typeCopy, keys);
|
||||
|
@ -4952,15 +4952,15 @@ bool client::postFunction(std::function<void(client *)> fn, bool fLock) {
|
||||
}, fLock) == AE_OK;
|
||||
}
|
||||
|
||||
std::vector<robj_sharedptr> client::args() {
|
||||
std::vector<robj_sharedptr> clientArgs(client *c) {
|
||||
std::vector<robj_sharedptr> args;
|
||||
for (int j = 1; j < this->argc; j++) {
|
||||
args.push_back(robj_sharedptr(argv[j]));
|
||||
for (int j = 1; j < c->argc; j++) {
|
||||
args.push_back(robj_sharedptr(c->argv[j]));
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
bool client::asyncCommand(std::function<void(const redisDbPersistentDataSnapshot *, std::vector<robj_sharedptr>)> &&mainFn,
|
||||
bool client::asyncCommand(std::function<void(const redisDbPersistentDataSnapshot *, const std::vector<robj_sharedptr> &)> &&mainFn,
|
||||
std::function<void(const redisDbPersistentDataSnapshot *)> &&postFn)
|
||||
{
|
||||
serverAssert(FCorrectThread(this));
|
||||
@ -4973,7 +4973,7 @@ bool client::asyncCommand(std::function<void(const redisDbPersistentDataSnapshot
|
||||
aeEventLoop *el = serverTL->el;
|
||||
blockClient(this, BLOCKED_ASYNC);
|
||||
g_pserver->asyncworkqueue->AddWorkFunction([el, this, mainFn, postFn, snapshot] {
|
||||
std::vector<robj_sharedptr> args = this->args();
|
||||
std::vector<robj_sharedptr> args = clientArgs(this);
|
||||
aePostFunction(el, [this, mainFn, postFn, snapshot, args] {
|
||||
aeReleaseLock();
|
||||
std::unique_lock<decltype(this->lock)> lock(this->lock);
|
||||
|
@ -1661,8 +1661,7 @@ struct client {
|
||||
// post a function from a non-client thread to run on its client thread
|
||||
bool postFunction(std::function<void(client *)> fn, bool fLock = true);
|
||||
size_t argv_len_sum() const;
|
||||
std::vector<robj_sharedptr> args();
|
||||
bool asyncCommand(std::function<void(const redisDbPersistentDataSnapshot *, std::vector<robj_sharedptr>)> &&mainFn,
|
||||
bool asyncCommand(std::function<void(const redisDbPersistentDataSnapshot *, const std::vector<robj_sharedptr> &)> &&mainFn,
|
||||
std::function<void(const redisDbPersistentDataSnapshot *)> &&postFn = nullptr);
|
||||
};
|
||||
|
||||
|
@ -544,7 +544,7 @@ void mgetCommand(client *c) {
|
||||
// Do async version for large number of arguments
|
||||
if (c->argc > 100) {
|
||||
if (c->asyncCommand(
|
||||
[c] (const redisDbPersistentDataSnapshot *snapshot, std::vector<robj_sharedptr> keys) {
|
||||
[c] (const redisDbPersistentDataSnapshot *snapshot, const std::vector<robj_sharedptr> &keys) {
|
||||
mgetCore(c, (robj **)keys.data(), keys.size(), snapshot);
|
||||
}
|
||||
)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user