Skip to content

chore: minor simplification around WaitWatch #4580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2025
Merged

chore: minor simplification around WaitWatch #4580

merged 1 commit into from
Feb 9, 2025

Conversation

romange
Copy link
Collaborator

@romange romange commented Feb 7, 2025

  1. Rename FinalizeWatched to RemovedWatched.
  2. Simplify passing of WatchedKeys - instead of passing a callback we pass either a single value or signal that all the shard keys should be used. Less generic but more explicit.

@romange romange force-pushed the Pr4 branch 3 times, most recently from 9804db9 to f4b8a14 Compare February 8, 2025 10:43
kostasrim
kostasrim previously approved these changes Feb 8, 2025
// Provides keys to block on for specific shard.
using WaitKeysProvider =
std::function<std::variant<ShardArgs, ArgSlice>(Transaction*, EngineShard* shard)>;
static constexpr std::nullopt_t kShardArgs{std::nullopt};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullopt to denote the type passed via a variable. Not bad 🤓

@@ -207,15 +207,14 @@ class Transaction {

// Called by engine shard to execute a transaction hop.
// txq_ooo is set to true if the transaction is running out of order
// not as the tx queue head.
// Returns true if the transaction continues running in the thread
// not as the tx queue head. Returns true if the transaction concludes.
Copy link
Contributor

@kostasrim kostasrim Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to check every RunInShard calls just to be sure the logic was inverted. Imo it's nicer now via the variable concludes 👍

1. Rename FinalizeWatched to RemovedWatched.
2. Simplify passing of WatchedKeys - instead of passing a callback
   we pass either a single value or signal that all the shard
   keys should be used. Less generic but more explicit.
3. Reverse the result from RunInShard() function - to improve readability.

All in all it should not have any functional changes besides logging.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
@romange romange merged commit 1331350 into main Feb 9, 2025
10 checks passed
@romange romange deleted the Pr4 branch February 9, 2025 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants