Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make task_writer to use imutable reference #87

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

ZENOTME
Copy link
Contributor

@ZENOTME ZENOTME commented Jul 13, 2023

Context

It seems unreasonable to me to have a mutable reference to create a task_writer, how about make the task_id an atomic variable?

Do we prepare make it be a shared-object. Otherwise, maybe RefCell馃?

Both LGTM, but I guess RefCell can't be Send

/// Return a task writer used to write data into table.
pub async fn task_writer(&mut self) -> Result<TaskWriter> {
    ...
    self.task_id += 1;
    Ok(task_writer)
}

So this PR use atomic usize instead of usize for task_id, make task_writer() to use imutable reference.

Copy link
Contributor

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

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

Thanks!

@Xuanwo Xuanwo merged commit 794f433 into icelake-io:main Jul 13, 2023
3 checks passed
@ZENOTME ZENOTME deleted the atomic branch July 13, 2023 07:09
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.

None yet

2 participants