Skip to content

c++11 memory order problem #1

Open
@wenzhang-dev

Description

@wenzhang-dev

Hi, It's like I found a treasure. but when I read you c++ code, one question confused me.

The mpmc_bounded_queue::size method calculate the size of enqueued nodes by acquire-relaxed memory order. What that means?

Getting head by acquire barrier, it easily understand. but why we should use following relaxed memory order to get enqueue_pos_?
I see the c++ spec about relaxed order, which only make sure that instruction is an atomic operation, but can't provide any synchorization. so the enqueue_pos_ variable may be an old value?

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions