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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove_listener 没有生效 #225

Open
bell152 opened this issue Apr 23, 2024 · 6 comments
Open

remove_listener 没有生效 #225

bell152 opened this issue Apr 23, 2024 · 6 comments
Labels
question Further information is requested

Comments

@bell152
Copy link

bell152 commented Apr 23, 2024

你好, 在一个新的进程中,执行remove_listener ,没有生效, 请问有什么其他要求吗?--或者Demo学习一下?

image

MacOS M2Max
rustup 1.27.0

@CherishCai
Copy link
Collaborator

remove_listener 指的是删除 listener ,它需要传入之前 add_listener 的那个实例。可以跟踪一下源码,它会做 equal 判断。

原因:一个 dataid 可能有多个 listener,只有 equal 才能判定是删除你所要删除的,而不是删了别的监听器

@CherishCai CherishCai added the question Further information is requested label Apr 23, 2024
@bell152
Copy link
Author

bell152 commented Apr 23, 2024

这么做可以么??用lazy_static! 包装了 Arc>,但是删除时还是失败了,有没有好办法?
image
image

@CherishCai
Copy link
Collaborator

建议 debug 看看为啥不成功。我工作中没有 Rust 项目,所以用的不多,也不怎么常见需要 remove listener 的,如果你研究有好的样例,也可以提一个 example 到仓库

@onewe
Copy link
Collaborator

onewe commented Apr 24, 2024

你要 remove listener 要保证和你添加的 listener 是同一个 listener

example:

let listener = Arc::new(listener);
NamingService.add(listener.clone());
NamingService.remove(listener);

@onewe
Copy link
Collaborator

onewe commented Apr 24, 2024

因为在 sdk 代码里面判断是不是同一个 listener 是按照地址来判断的, 所以需要保证是同一个 listener

@onewe
Copy link
Collaborator

onewe commented Apr 24, 2024

有啥错误信息么? 或者 你提供一个 复现这个问题的 demo 我研究研究

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants