@@ -15,17 +15,13 @@ TEST_CASE("unbounded_queue_shrink")
15
15
constexpr size_t CHUNK{256 };
16
16
constexpr size_t INITIAL_SIZE{1024 };
17
17
18
- UnboundedSPSCQueue buffer{INITIAL_SIZE};
18
+ UnboundedSPSCQueue buffer{INITIAL_SIZE, quill::FrontendOptions::unbounded_queue_max_capacity };
19
19
REQUIRE_EQ (buffer.producer_capacity (), INITIAL_SIZE);
20
20
21
21
// This queue will grow as we request 5 * 256
22
22
for (uint32_t i = 0 ; i < 5 ; ++i)
23
23
{
24
- #if defined(_MSC_VER)
25
- auto * write_buffer = buffer.prepare_write (CHUNK, quill::FrontendOptions::unbounded_queue_max_capacity);
26
- #else
27
- auto * write_buffer = buffer.prepare_write <quill::FrontendOptions::unbounded_queue_max_capacity>(CHUNK);
28
- #endif
24
+ auto * write_buffer = buffer.prepare_write (CHUNK);
29
25
30
26
REQUIRE (write_buffer);
31
27
buffer.finish_write (CHUNK);
@@ -69,19 +65,15 @@ TEST_CASE("unbounded_queue_shrink")
69
65
70
66
TEST_CASE (" unbounded_queue_allocation_within_limit" )
71
67
{
72
- UnboundedSPSCQueue buffer{1024 };
68
+ UnboundedSPSCQueue buffer{1024 , std::numeric_limits< uint64_t >:: max () };
73
69
74
70
static constexpr size_t two_mb = 2u * 1024u * 1024u ;
75
71
76
72
// Attempt to allocate a buffer size that exceeds the default limit,
77
73
// ensuring that allocation within configurable bounds does not throw.
78
74
auto func = [&buffer]()
79
75
{
80
- #if defined(_MSC_VER)
81
- auto * write_buffer_z = buffer.prepare_write (2 * two_mb, std::numeric_limits<uint64_t >::max ());
82
- #else
83
- auto * write_buffer_z = buffer.prepare_write <std::numeric_limits<uint64_t >::max ()>(2 * two_mb);
84
- #endif
76
+ auto * write_buffer_z = buffer.prepare_write (2 * two_mb);
85
77
return write_buffer_z;
86
78
};
87
79
@@ -91,19 +83,15 @@ TEST_CASE("unbounded_queue_allocation_within_limit")
91
83
92
84
TEST_CASE (" unbounded_queue_allocation_exceeds_limit" )
93
85
{
94
- UnboundedSPSCQueue buffer{1024 };
95
-
96
86
constexpr static uint64_t two_mb = 2u * 1024u * 1024u ;
97
87
88
+ UnboundedSPSCQueue buffer{1024 , two_mb};
89
+
98
90
// Attempt to allocate a buffer size that exceeds the specified capacity,
99
91
// which should trigger an exception.
100
92
auto func = [&buffer]()
101
93
{
102
- #if defined(_MSC_VER)
103
- auto * write_buffer_z = buffer.prepare_write (2 * two_mb, two_mb);
104
- #else
105
- auto * write_buffer_z = buffer.prepare_write <two_mb>(2 * two_mb);
106
- #endif
94
+ auto * write_buffer_z = buffer.prepare_write (2 * two_mb);
107
95
return write_buffer_z;
108
96
};
109
97
@@ -113,7 +101,7 @@ TEST_CASE("unbounded_queue_allocation_exceeds_limit")
113
101
114
102
TEST_CASE (" unbounded_queue_read_write_multithreaded_plain_ints" )
115
103
{
116
- UnboundedSPSCQueue buffer{1024 };
104
+ UnboundedSPSCQueue buffer{1024 , quill::FrontendOptions::unbounded_queue_max_capacity };
117
105
118
106
std::thread producer_thread (
119
107
[&buffer]()
@@ -122,25 +110,15 @@ TEST_CASE("unbounded_queue_read_write_multithreaded_plain_ints")
122
110
{
123
111
for (uint32_t i = 0 ; i < 8192 ; ++i)
124
112
{
125
- #if defined(_MSC_VER)
126
- auto * write_buffer =
127
- buffer.prepare_write (sizeof (uint32_t ), quill::FrontendOptions::unbounded_queue_max_capacity);
128
- #else
129
113
auto * write_buffer =
130
- buffer.prepare_write <quill::FrontendOptions::unbounded_queue_max_capacity>(sizeof (uint32_t ));
131
- #endif
114
+ buffer.prepare_write (sizeof (uint32_t ));
132
115
133
116
while (!write_buffer)
134
117
{
135
118
std::this_thread::sleep_for (std::chrono::microseconds{2 });
136
- #if defined(_MSC_VER)
137
- write_buffer =
138
- buffer.prepare_write (sizeof (uint32_t ), quill::FrontendOptions::unbounded_queue_max_capacity);
139
- #else
119
+
140
120
write_buffer =
141
- buffer.prepare_write <quill::FrontendOptions::unbounded_queue_max_capacity>(
142
- sizeof (uint32_t ));
143
- #endif
121
+ buffer.prepare_write (sizeof (uint32_t ));
144
122
}
145
123
146
124
std::memcpy (write_buffer, &i, sizeof (uint32_t ));
0 commit comments