RFR: 8229517: Support for optional asynchronous/buffered logging [v17]

Albert Mingkun Yang ayang at openjdk.java.net
Fri May 21 18:46:42 UTC 2021


On Fri, 21 May 2021 17:17:36 GMT, Xin Liu <xliu at openjdk.org> wrote:

>> src/hotspot/share/logging/logAsyncWriter.cpp line 167:
>> 
>>> 165:     AsyncLogWriter* self = new AsyncLogWriter();
>>> 166: 
>>> 167:     if (self->_state == ThreadState::Initialized) {
>> 
>> The content of this `if` could be inlined to the constructor, and `ThreadState::Initialized` could be removed then, right?
>
> but it's not exceptional safe. I know hotspot doesn't use c++ exception, but the general principle still applys. 
> the more logics in ctor, the more likely to fail.  So far, if something wrong, I left self in state of `NotReady`.

Since hotspot does not use c++ exception, I don't really follow the reasoning of "the more logics in ctor, the more likely to fail". Code doesn't just fail mysteriously. The only thing that could "fail" here is `new AsyncLogWriter()` returns `nullptr`, I think.

Anyway, this is just a suggestion; feel free to go for the style you prefer.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3135


More information about the hotspot-dev mailing list