8000 单链表中的size可否添加原子操作限定符 · Issue #222 · tboox/tbox · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
单链表中的size可否添加原子操作限定符 #222
Open
@misskimi

Description

用tbox实现一个生产者消费者模型,其中包含了生产者信号量、消费者信号量、队列、锁,调试中发现锁操作太耗时,想着去掉锁。但发现队列是用单链表实现的,而单链表里有对变量size进行自增自减操作,这个在多核下会出问题。
有什么解决办法吗?想着将size的类型改成tb_atomic_t,然后把size相关的操作都改下,可以吗?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0