Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Signal watcher functionality with test #597

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vertexodessa
Copy link
Contributor

@vertexodessa vertexodessa commented May 1, 2017

The idea is to have simple macros which will allow to dump the current profiling result to a file by issuing "kill" shell command.

@vertexodessa vertexodessa force-pushed the SignalWatcher branch 6 times, most recently from d3a62e5 to 5ed87d2 Compare May 1, 2017 22:10
@vertexodessa vertexodessa changed the title Signal watcher functionality with test (std threading only) Signal watcher functionality with test May 1, 2017
@vertexodessa vertexodessa force-pushed the SignalWatcher branch 3 times, most recently from 7bc5f48 to be3a26e Compare May 1, 2017 22:16
@vertexodessa
Copy link
Contributor Author

@stellaeof hi Stella, could you please review..
I had to steal std::thread, std::unique_lock and std::condition to pthread platform implementation, not sure how critical is that, considering the fact there are other std usages in pthread.
Maybe we'll have to implement them using pthread primitives as a refactoring step later if that works?

@stellaraccident
Copy link

stellaraccident commented May 2, 2017 via email

@vertexodessa
Copy link
Contributor Author

vertexodessa commented May 7, 2017

@stellaeof hi Stella, thanks for the review, I've updated the pull request according to your suggestions and added the test.

Copy link

@stellaraccident stellaraccident left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry this took so long - I was traveling. I've noted a number of nits where this code doesn't match the style guide the rest was written to, but I don't want to hold up your contribution. Feel free to submit and I can cleanup later (or there is a script in there to run clang-format, which I think will fix most of it).

The biggest naming thing is that functions are NamedLikeThis and variables are named_like_this.

return;
}

static bool onlyOnce = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still a bit racy. I typically see a std::atomic used for this (with a condition on if (only_once.exchange(true))).


#include "gtest/gtest.h"

char const* kSignalWatcherFilename = "./tmptstsignal_watcher.wtf-trace";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer: const char kSignalWatcherFilename[]


TEST_F(PosixUtilsTest, SignalWatcher) {
unlink(kSignalWatcherFilename);
// watch SIGALRM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

usleep(5000 * second);

alarm(0);
// allow the thread to finish it's work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent.

EXPECT_TRUE(stat(kSignalWatcherFilename, &buffer) == 0);
EXPECT_TRUE(buffer.st_size > 0);
}
} //namespace wtf

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space between comment and "namespace"

@vertexodessa
Copy link
Contributor Author

@stellaeof Stella, thanks a lot for the review. I updated the code-review according to your comments.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants