Skip to content

Conversation

@ifplusor
Copy link
Contributor

@ifplusor ifplusor commented Jan 24, 2019

#77 replace lock with fetch_add(1) when allocate opaque

@ShannonDing ShannonDing added the enhancement New feature or request label Jan 25, 2019
@ShannonDing ShannonDing added this to the 1.2.2 milestone Jan 25, 2019
@ifplusor ifplusor closed this Jan 27, 2019
@ifplusor ifplusor reopened this Jan 27, 2019
++s_seqNumber;

// mask sign bit
m_opaque = s_seqNumber.fetch_add(1, boost::memory_order_acq_rel) & numeric_limits<int>::max();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we only need an atomic incremental number and no memory barrier is required, boost::memory_order_relaxed should be fine here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. yesterday, i change this to 'memory_order_acq_rel' when i try to fix other bug, but that have no relation to memory order. i have revert it.

@lizhanhui
Copy link
Contributor

+1 to get this pull request merged.

@ShannonDing ShannonDing merged commit af5a1bf into apache:master Feb 15, 2019
@ifplusor ifplusor deleted the optimize-opaque branch February 15, 2019 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants