Skip to content

fix: use RAII to release resources in async task - #1502

Merged
AlexStocks merged 3 commits into
OpenAtomFoundation:unstablefrom
A2ureStone:raii_improve
May 16, 2023
Merged

fix: use RAII to release resources in async task#1502
AlexStocks merged 3 commits into
OpenAtomFoundation:unstablefrom
A2ureStone:raii_improve

Conversation

@A2ureStone

Copy link
Copy Markdown
Contributor

No description provided.

@wanghenshui wanghenshui changed the title use raii to release resources in async task fix: use raii to release resources in async task May 15, 2023
@AlexStocks AlexStocks changed the title fix: use raii to release resources in async task fix: use RAII to release resources in async task May 15, 2023
@AlexStocks

Copy link
Copy Markdown
Contributor

image

如果 arg 是 new 出来的,这么改动,能保证 arg 会被释放掉么?

@A2ureStone

Copy link
Copy Markdown
Contributor Author

可以的, unique_ptr接受一个指针, 在析构的时候调用对应参数类型的delete函数

Comment thread src/pika_client_conn.cc Outdated
Comment thread src/pika_repl_bgworker.cc Outdated
@loveyacper

loveyacper commented May 16, 2023

Copy link
Copy Markdown
Collaborator

传递void*指针,基本是编码设计上的缺陷,本次修改治标。若治本,未来要解决掉 void*

@AlexStocks
AlexStocks merged commit 979d16d into OpenAtomFoundation:unstable May 16, 2023
bigdaronlee163 pushed a commit to bigdaronlee163/pika that referenced this pull request Jun 8, 2024
…1502)

* use raii to release resources in async task

* use static_cast instead of reinterpret_cast

---------

Co-authored-by: J1senn <J1senn@outlook.com>
cheniujh pushed a commit to cheniujh/pika that referenced this pull request Sep 24, 2024
…1502)

* use raii to release resources in async task

* use static_cast instead of reinterpret_cast

---------

Co-authored-by: J1senn <J1senn@outlook.com>
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.

4 participants