summaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/util/queue_chunk.h
blob: 96657ee8905f916ef26f76455ccece568d708d50 (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)); 
    } 
};