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

请教一下如何正确创建多个Client? #54

Open
yuzu-ogura opened this issue Oct 10, 2024 · 1 comment
Open

请教一下如何正确创建多个Client? #54

yuzu-ogura opened this issue Oct 10, 2024 · 1 comment

Comments

@yuzu-ogura
Copy link

您好,我想请教一下,如何正确创建多个Client?

我看您的给出的示例中,有一个clients_cross_thread例子中包含创建多个Client的场景,例子中的做法是在调用loop->run()之前,完成所有Client的构造,我的疑惑就是如果想动态创建Client,或者说在loop->run()启动以后,要怎么正确创建多个Client呢?

@wlgq2
Copy link
Owner

wlgq2 commented Oct 14, 2024

在你client的loop下任意回调函数里创建,比如定时器,结束消息回调。如果没有回调,可以
loop->runInThisLoop({
client = new client
})
否则,因为libuv本身不是线程安全,会core dump。

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

No branches or pull requests

2 participants