Skip to content

Commit 696287d

Browse files
author
Xin Liu
committedSep 22, 2022
8294037: Using alias template to unify hashtables in AsyncLogWriter
Reviewed-by: coleenp, simonis
1 parent 48cc156 commit 696287d

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed
 

‎src/hotspot/share/logging/logAsyncWriter.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,7 @@ AsyncLogWriter::AsyncLogWriter()
116116

117117
void AsyncLogWriter::write() {
118118
ResourceMark rm;
119-
// Similar to AsyncLogMap but on resource_area
120-
ResourceHashtable<LogFileStreamOutput*, uint32_t,
121-
17/*table_size*/, ResourceObj::RESOURCE_AREA,
122-
mtLogging> snapshot;
119+
AsyncLogMap<ResourceObj::RESOURCE_AREA> snapshot;
123120

124121
// lock protection. This guarantees I/O jobs don't block logsites.
125122
{

‎src/hotspot/share/logging/logAsyncWriter.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ class AsyncLogWriter : public NonJavaThread {
5858
friend class AsyncLogTest;
5959
friend class AsyncLogTest_logBuffer_vm_Test;
6060
class AsyncLogLocker;
61+
62+
// account for dropped messages
63+
template <ResourceObj::allocation_type ALLOC_TYPE>
6164
using AsyncLogMap = ResourceHashtable<LogFileStreamOutput*,
62-
uint32_t,
63-
17, /*table_size*/
64-
ResourceObj::C_HEAP,
65-
mtLogging>;
65+
uint32_t, 17, /*table_size*/
66+
ALLOC_TYPE, mtLogging>;
6667

6768
// Messsage is the envelop of a log line and its associative data.
6869
// Its length is variable because of the zero-terminated c-str. It is only valid when we create it using placement new
@@ -154,7 +155,7 @@ class AsyncLogWriter : public NonJavaThread {
154155
PlatformMonitor _lock;
155156
bool _data_available;
156157
volatile bool _initialized;
157-
AsyncLogMap _stats; // statistics for dropped messages
158+
AsyncLogMap<ResourceObj::C_HEAP> _stats;
158159

159160
// ping-pong buffers
160161
Buffer* _buffer;

0 commit comments

Comments
 (0)
Please sign in to comment.