Skip to content

Refactor CassFuture state management - more type safety and clarity #302

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wprzytula
Copy link
Collaborator

This PR refactors CassFutureState, so that it is represented in a more type-safe way.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • PR description sums up the changes and reasons why they should be introduced.
  • [ ] I have implemented Rust unit tests for the features/changes introduced.
  • [ ] I have enabled appropriate tests in .github/workflows/build.yml in gtest_filter.
  • [ ] I have enabled appropriate tests in .github/workflows/cassandra.yml in gtest_filter.

wprzytula added 2 commits May 19, 2025 16:47
I believe the Default trait gives no benefit there. Also, this prepares
for subsequent commits with the refactor.
@wprzytula wprzytula requested review from muzarski and Lorak-mmk May 19, 2025 13:51
The refactor involves employing an enum to represent the state of the
future: `CassFutureExecution`. This enum has three variants:
- `RunningWithoutCallback`: Indicates that the future is currently running
  without a callback,
- `RunningWithCallback`: Indicates that the future is running with a
  callback,
- `Completed`: Indicates that the future has completed, and it contains
  the result of the future.

I hope this refactor makes the state transitions clearer and easier to
understand, and, even more importantly, more bug-resistant.
@wprzytula wprzytula force-pushed the refactor-cass-future branch from d4851b3 to 78102ad Compare May 19, 2025 13:56
@muzarski
Copy link
Contributor

Have you looked at https://github.com/scylladb/cpp-rust-driver/pull/299/commits?

Especially: 25cb370 and 665266c. Would you be able to do such refactor on top of them?

TLDR, I don't want to store CassFutureResult behind a mutex (as it currently is), but rather inside of OnceLock.

@wprzytula
Copy link
Collaborator Author

Have you looked at https://github.com/scylladb/cpp-rust-driver/pull/299/commits?

Not yet...

Especially: 25cb370 and 665266c. Would you be able to do such refactor on top of them?

TLDR, I don't want to store CassFutureResult behind a mutex (as it currently is), but rather inside of OnceLock.

OK, I'll try to port it once we merge #299.

@wprzytula wprzytula self-assigned this May 26, 2025
@wprzytula
Copy link
Collaborator Author

The refactor got severaly outdated after #299. It requires significant changes. Moving to draft for now.

@wprzytula wprzytula marked this pull request as draft June 4, 2025 08:36
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