aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/util/queue_chunk.h
blob: b56f0c1d5c015bdd1738b6510a21f0254d90bc7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include "defs.h"

template <typename T, ui32 TSize, typename TDerived>
struct TQueueChunkDerived {
    static const ui32 EntriesCount = (TSize - sizeof(TQueueChunkDerived*)) / sizeof(T);
    static_assert(EntriesCount > 0, "expect EntriesCount > 0"); 

    volatile T Entries[EntriesCount];
    TDerived* volatile Next;

    TQueueChunkDerived() {
        memset(this, 0, sizeof(TQueueChunkDerived));
    }
};

template <typename T, ui32 TSize>
struct TQueueChunk {
    static const ui32 EntriesCount = (TSize - sizeof(TQueueChunk*)) / sizeof(T);
    static_assert(EntriesCount > 0, "expect EntriesCount > 0"); 

    volatile T Entries[EntriesCount];
    TQueueChunk* volatile Next;

    TQueueChunk() {
        memset(this, 0, sizeof(TQueueChunk));
    }
};