Skip to content

Commit

Permalink
Fixed linting issues in tracing folder
Browse files Browse the repository at this point in the history
fix: #14490
  • Loading branch information
Jeyanthinath committed Jul 28, 2017
1 parent f42a3d6 commit 29638c6
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/tracing/agent.h
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
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
8 changes: 4 additions & 4 deletions src/tracing/node_trace_buffer.h
@@ -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,7 @@ 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.
// TODO(misterpoe) : Change std::atomic to something less contentious.
std::atomic<InternalTraceBuffer*> current_buf_;
InternalTraceBuffer buffer1_;
InternalTraceBuffer buffer2_;
Expand All @@ -84,4 +84,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
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(misterpoe) : 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
@@ -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_
5 changes: 3 additions & 2 deletions src/tracing/trace_event.h
Expand Up @@ -453,8 +453,9 @@ INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string,
#undef INTERNAL_DECLARE_SET_TRACE_VALUE
#undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT

static inline void SetTraceValue(v8::ConvertableToTraceFormat* convertable_value,
unsigned char* type, uint64_t* value) {
static inline void SetTraceValue(
v8::ConvertableToTraceFormat* convertable_value,
unsigned char* type, uint64_t* value) {
*type = TRACE_VALUE_TYPE_CONVERTABLE;
*value = static_cast<uint64_t>(reinterpret_cast<intptr_t>(convertable_value));
}
Expand Down
5 changes: 5 additions & 0 deletions src/tracing/trace_event_common.h
Expand Up @@ -189,6 +189,9 @@
// trace points would carry a significant performance cost of acquiring a lock
// and resolving the category.

#ifndef SRC_TRACING_TRACE_EVENT_COMMON_H_
#define SRC_TRACING_TRACE_EVENT_COMMON_H_

#if defined(TRACE_EVENT0)
#error "Another copy of this file has already been included."
#endif
Expand Down Expand Up @@ -1071,3 +1074,5 @@
#define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
#define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
#define TRACE_EVENT_SCOPE_NAME_THREAD ('t')

#endif // SRC_TRACING_TRACE_EVENT_COMMON_H_

0 comments on commit 29638c6

Please sign in to comment.