Skip to content

Commit

Permalink
Fix : ELEMENTS_PER_BLOCK may be incorrect (apache#2562)
Browse files Browse the repository at this point in the history
* fix bug ELEMENTS_PER_BLOCK in doubly_buffered_data.h

* fix bug ELEMENTS_PER_BLOCK in doubly_buffered_data.h

* fix bug ELEMENTS_PER_BLOCK in doubly_buffered_data.h
  • Loading branch information
shanhe72101 authored Mar 13, 2024
1 parent 965279f commit 216aa59
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/butil/containers/doubly_buffered_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ template <typename T, typename TLS, bool AllowBthreadSuspended>
class DoublyBufferedData<T, TLS, AllowBthreadSuspended>::WrapperTLSGroup {
public:
const static size_t RAW_BLOCK_SIZE = 4096;
const static size_t ELEMENTS_PER_BLOCK = (RAW_BLOCK_SIZE + sizeof(T) - 1) / sizeof(T);
const static size_t ELEMENTS_PER_BLOCK = RAW_BLOCK_SIZE / sizeof(Wrapper) > 0 ? RAW_BLOCK_SIZE / sizeof(Wrapper) : 1;

struct BAIDU_CACHELINE_ALIGNMENT ThreadBlock {
inline DoublyBufferedData::Wrapper* at(size_t offset) {
Expand Down Expand Up @@ -359,7 +359,7 @@ __thread std::vector<typename DoublyBufferedData<T, TLS, AllowBthreadSuspended>:
DoublyBufferedData<T, TLS, AllowBthreadSuspended>::WrapperTLSGroup::_s_tls_blocks = NULL;

template <typename T, typename TLS, bool AllowBthreadSuspended>
class DoublyBufferedData<T, TLS, AllowBthreadSuspended>::Wrapper
class BAIDU_CACHELINE_ALIGNMENT DoublyBufferedData<T, TLS, AllowBthreadSuspended>::Wrapper
: public DoublyBufferedDataWrapperBase<T, TLS> {
friend class DoublyBufferedData;
public:
Expand Down

0 comments on commit 216aa59

Please sign in to comment.