Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: runtime/bin/signal_blocker.h

Issue 109803002: Profiler Take 2 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/bin/signal_blocker.h
diff --git a/runtime/bin/signal_blocker.h b/runtime/bin/signal_blocker.h
new file mode 100644
index 0000000000000000000000000000000000000000..d01e531ebcd24c7f64f6ee1c19a0700098b74679
--- /dev/null
+++ b/runtime/bin/signal_blocker.h
@@ -0,0 +1,41 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef BIN_SIGNAL_BLOCKER_H_
+#define BIN_SIGNAL_BLOCKER_H_
+
+#include "platform/globals.h"
+
+#if defined(TARGET_OS_WINDOWS)
+#error Do not include this file on Windows.
+#endif
+
+#include <signal.h> // NOLINT
+
+namespace dart {
+namespace bin {
+
+class ThreadSignalBlocker {
+ public:
+ explicit ThreadSignalBlocker(int sig) {
+ sigset_t signal_mask;
+ sigemptyset(&signal_mask);
+ sigaddset(&signal_mask, sig);
+ // Add sig to signal mask.
+ pthread_sigmask(SIG_BLOCK, &signal_mask, &old);
siva 2013/12/13 21:29:14 int result = pthread_sigmask(....); ASSERT(!retval
Cutch 2013/12/13 22:40:18 Done.
+ }
+
+ ~ThreadSignalBlocker() {
+ // Restore signal mask.
+ pthread_sigmask(SIG_SETMASK, &old, NULL);
siva 2013/12/13 21:29:14 Ditto here.
Cutch 2013/12/13 22:40:18 Done.
+ }
+
+ private:
+ sigset_t old;
+};
+
+} // namespace bin
+} // namespace dart
+
+#endif // BIN_SIGNAL_BLOCKER_H_

Powered by Google App Engine
This is Rietveld 408576698