【咨询】bthread 互斥锁为什么不像 pthread 互斥锁一样实现递归锁(可重入锁)?
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by reading the bthread_mutex_init implementation and the Goals section of the documentation, then compare its attr handling with pthread mutex behavior. Determine whether recursive locking is intended to be supported and whether existing bthread-level implementations or examples are referenced. Done means the compatibility question has a documented resolution or a clearly scoped implementation plan.
Written by the indexing model from the issue text.
Description
我需要将原本运行在 pthread 上的业务切换到 bthread 上,但有的业务中 pthread 互斥锁设置了属性 PTHREAD_MUTEX_RECURSIVE_NP,这导致无法直接实现 bthread 切换。
我看了 bthread_mutex_init 源码实现,虽然有 attr 参数,但是看上去是为了兼容 pthread_mutex_init,其实忽略了 attr 参数。
为什么不做实现呢?这与官方文档 Goals 章节所述“bthread所有接口可在pthread中被调用并有合理的行为,使用bthread的代码可以在pthread中正常执行。”并不完全准确。
如果需要兼容,看上去我需要参考 pthread,基于 bthread 封装一个实现,添加 owner id 和ref_ count 来实现 bthread 级别的递归锁,有这样的实现案例吗?
- Dominant language
- C++
- Stars
- 17.6k
- Forks
- 4.2k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 72
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/brpc
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days
-
endpoint2hostname() prints a byte-swapped port for IPv6 endpointsPossibly taken @0z5a claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
perf(butil): ARM64 (aarch64) performance and modernisation improvements across atomics, CRC32C, spin-wait hints, and fast timersPossibly taken @jimmystewpot claimed this 2 days ago. Open
Difficulty 5/5 Over a week Newbie friendliness 12/100
Maintainers usually reply within 2 days
-
file:// naming service takes a comment after the address as the tagPossibly taken @0z5a claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Maintainers usually reply within 2 days
Similar issues
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day
-
Android: with view recycling on, a recycled View keeps its nextFocusLeftPossibly taken A pull request linked to this issue is open or already merged. OpenNeeds: Triage :mag: Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/react-native#60167 ·
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 63/100