Skip to content

Commit

Permalink
build: enable C++ linting for src/*/*
Browse files Browse the repository at this point in the history
Fixes: #14490
PR-URL: #14497
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Refael Ackermann <refack@gmail.com>
  • Loading branch information
Jeyanthinath authored and addaleax committed Aug 7, 2017
1 parent 8c5cd14 commit c0f0c38
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 21 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -891,11 +891,16 @@ CPPLINT_EXCLUDE += src/queue.h
CPPLINT_EXCLUDE += src/tree.h
CPPLINT_EXCLUDE += $(wildcard test/addons/??_*/*.cc test/addons/??_*/*.h)
CPPLINT_EXCLUDE += $(wildcard test/addons-napi/??_*/*.cc test/addons-napi/??_*/*.h)
# These files were copied more or less verbatim from V8.
CPPLINT_EXCLUDE += src/tracing/trace_event.h src/tracing/trace_event_common.h

CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \
src/*.c \
src/*.cc \
src/*.h \
src/*/*.c \
src/*/*.cc \
src/*/*.h \
test/addons/*/*.cc \
test/addons/*/*.h \
test/cctest/*.cc \
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace tracing {

class Agent {
public:
explicit Agent();
Agent();
void Start(v8::Platform* platform, const std::string& enabled_categories);
void Stop();

Expand Down
13 changes: 8 additions & 5 deletions src/tracing/node_trace_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ NodeTraceBuffer::NodeTraceBuffer(size_t max_chunks,
current_buf_.store(&buffer1_);

flush_signal_.data = this;
int err = uv_async_init(tracing_loop_, &flush_signal_, NonBlockingFlushSignalCb);
int err = uv_async_init(tracing_loop_, &flush_signal_,
NonBlockingFlushSignalCb);
CHECK_EQ(err, 0);

exit_signal_.data = this;
Expand All @@ -105,7 +106,7 @@ NodeTraceBuffer::NodeTraceBuffer(size_t max_chunks,
NodeTraceBuffer::~NodeTraceBuffer() {
uv_async_send(&exit_signal_);
Mutex::ScopedLock scoped_lock(exit_mutex_);
while(!exited_) {
while (!exited_) {
exit_cond_.Wait(scoped_lock);
}
}
Expand Down Expand Up @@ -138,7 +139,7 @@ bool NodeTraceBuffer::Flush() {
bool NodeTraceBuffer::TryLoadAvailableBuffer() {
InternalTraceBuffer* prev_buf = current_buf_.load();
if (prev_buf->IsFull()) {
uv_async_send(&flush_signal_); // trigger flush on a separate thread
uv_async_send(&flush_signal_); // trigger flush on a separate thread
InternalTraceBuffer* other_buf = prev_buf == &buffer1_ ?
&buffer2_ : &buffer1_;
if (!other_buf->IsFull()) {
Expand All @@ -165,8 +166,10 @@ void NodeTraceBuffer::NonBlockingFlushSignalCb(uv_async_t* signal) {
void NodeTraceBuffer::ExitSignalCb(uv_async_t* signal) {
NodeTraceBuffer* buffer = reinterpret_cast<NodeTraceBuffer*>(signal->data);
uv_close(reinterpret_cast<uv_handle_t*>(&buffer->flush_signal_), nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&buffer->exit_signal_), [](uv_handle_t* signal) {
NodeTraceBuffer* buffer = reinterpret_cast<NodeTraceBuffer*>(signal->data);
uv_close(reinterpret_cast<uv_handle_t*>(&buffer->exit_signal_),
[](uv_handle_t* signal) {
NodeTraceBuffer* buffer =
reinterpret_cast<NodeTraceBuffer*>(signal->data);
Mutex::ScopedLock scoped_lock(buffer->exit_mutex_);
buffer->exited_ = true;
buffer->exit_cond_.Signal(scoped_lock);
Expand Down
7 changes: 3 additions & 4 deletions src/tracing/node_trace_buffer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SRC_NODE_TRACE_BUFFER_H_
#define SRC_NODE_TRACE_BUFFER_H_
#ifndef SRC_TRACING_NODE_TRACE_BUFFER_H_
#define SRC_TRACING_NODE_TRACE_BUFFER_H_

#include "node_mutex.h"
#include "tracing/node_trace_writer.h"
Expand Down Expand Up @@ -75,7 +75,6 @@ class NodeTraceBuffer : public TraceBuffer {
// Used to wait until async handles have been closed.
ConditionVariable exit_cond_;
std::unique_ptr<NodeTraceWriter> trace_writer_;
// TODO: Change std::atomic to something less contentious.
std::atomic<InternalTraceBuffer*> current_buf_;
InternalTraceBuffer buffer1_;
InternalTraceBuffer buffer2_;
Expand All @@ -84,4 +83,4 @@ class NodeTraceBuffer : public TraceBuffer {
} // namespace tracing
} // namespace node

#endif // SRC_NODE_TRACING_CONTROLLER_H_
#endif // SRC_TRACING_NODE_TRACE_BUFFER_H_
17 changes: 10 additions & 7 deletions src/tracing/node_trace_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void NodeTraceWriter::WriteSuffix() {
{
Mutex::ScopedLock scoped_lock(stream_mutex_);
if (total_traces_ > 0) {
total_traces_ = 0; // so we don't write it again in FlushPrivate
total_traces_ = 0; // so we don't write it again in FlushPrivate
// Appends "]}" to stream_.
delete json_trace_writer_;
should_flush = true;
Expand All @@ -49,7 +49,7 @@ NodeTraceWriter::~NodeTraceWriter() {
}
uv_async_send(&exit_signal_);
Mutex::ScopedLock scoped_lock(request_mutex_);
while(!exited_) {
while (!exited_) {
exit_cond_.Wait(scoped_lock);
}
}
Expand Down Expand Up @@ -110,8 +110,8 @@ void NodeTraceWriter::FlushSignalCb(uv_async_t* signal) {
trace_writer->FlushPrivate();
}

// TODO: Remove (is it necessary to change the API? Since because of WriteSuffix
// it no longer matters whether it's true or false)
// TODO(matthewloring): Remove (is it necessary to change the API?
// Since because of WriteSuffix it no longer matters whether it's true or false)
void NodeTraceWriter::Flush() {
Flush(true);
}
Expand Down Expand Up @@ -172,9 +172,12 @@ void NodeTraceWriter::WriteCb(uv_fs_t* req) {
// static
void NodeTraceWriter::ExitSignalCb(uv_async_t* signal) {
NodeTraceWriter* trace_writer = static_cast<NodeTraceWriter*>(signal->data);
uv_close(reinterpret_cast<uv_handle_t*>(&trace_writer->flush_signal_), nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&trace_writer->exit_signal_), [](uv_handle_t* signal) {
NodeTraceWriter* trace_writer = static_cast<NodeTraceWriter*>(signal->data);
uv_close(reinterpret_cast<uv_handle_t*>(&trace_writer->flush_signal_),
nullptr);
uv_close(reinterpret_cast<uv_handle_t*>(&trace_writer->exit_signal_),
[](uv_handle_t* signal) {
NodeTraceWriter* trace_writer =
static_cast<NodeTraceWriter*>(signal->data);
Mutex::ScopedLock scoped_lock(trace_writer->request_mutex_);
trace_writer->exited_ = true;
trace_writer->exit_cond_.Signal(scoped_lock);
Expand Down
8 changes: 4 additions & 4 deletions src/tracing/node_trace_writer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef SRC_NODE_TRACE_WRITER_H_
#define SRC_NODE_TRACE_WRITER_H_
#ifndef SRC_TRACING_NODE_TRACE_WRITER_H_
#define SRC_TRACING_NODE_TRACE_WRITER_H_

#include <sstream>
#include <queue>
Expand All @@ -17,7 +17,7 @@ using v8::platform::tracing::TracingController;

class NodeTraceWriter : public TraceWriter {
public:
NodeTraceWriter(uv_loop_t* tracing_loop);
explicit NodeTraceWriter(uv_loop_t* tracing_loop);
~NodeTraceWriter();

void AppendTraceEvent(TraceObject* trace_event) override;
Expand Down Expand Up @@ -71,4 +71,4 @@ class NodeTraceWriter : public TraceWriter {
} // namespace tracing
} // namespace node

#endif // SRC_NODE_TRACE_WRITER_H_
#endif // SRC_TRACING_NODE_TRACE_WRITER_H_

0 comments on commit c0f0c38

Please sign in to comment.