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

bthread_setconcurrency相关的使用优化 #2627

Closed
yanglimingcn opened this issue Apr 30, 2024 · 2 comments
Closed

bthread_setconcurrency相关的使用优化 #2627

yanglimingcn opened this issue Apr 30, 2024 · 2 comments

Comments

@yanglimingcn
Copy link
Contributor

Describe the bug (描述bug)

bthread_min_concurrency/bthread_concurrency/bthread_current_tag/bthread_concurrency_by_tag现在使用起来很不友好,感觉可以优化一下。
这些值的实际生效都是在bthread的worker都启动完成后再去执行,感觉就会比较符合预期,比较可控。所以可以将这些函数中的
TaskControl* c = get_task_control(); 代码改成 TaskControl* c = get_or_new_task_control(); 再去调用相关的修改逻辑。这样整体代码会简洁很多,这几个参数的依赖性也就没那么强了。尤其是bthread_current_tag/bthread_concurrency_by_tag,在没有启动好worker前调用其实是不能生效的,这就很别扭。

这么做的弊端是这些worker的启动会提前一些,但是,既然是用户设置的感觉提前启动也没啥问题。

To Reproduce (复现方法)

Expected behavior (期望行为)

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

Additional context/screenshots (更多上下文/截图)

@yanglimingcn
Copy link
Contributor Author

@wwbmmm 这块你有啥建议吗?

@yanglimingcn
Copy link
Contributor Author

#2628

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

1 participant