projects
/
awesomized
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Update from latest ddm4
[awesomized/libmemcached]
/
libtest
/
signal.h
diff --git
a/libtest/signal.h
b/libtest/signal.h
index beb28b22a478aa6fe90a33eeee1f3d4ff3efaaec..fd7e4a6d359287ba925a7607ba0e9033b14e89be 100644
(file)
--- a/
libtest/signal.h
+++ b/
libtest/signal.h
@@
-1,8
+1,8
@@
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * uTest, libtest
*
*
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@
-34,23
+34,46
@@
*
*/
*
*/
-
#pragma once
#pragma once
+#include <pthread.h>
+#include <semaphore.h>
+#include <signal.h>
+
enum shutdown_t {
SHUTDOWN_RUNNING,
SHUTDOWN_GRACEFUL,
SHUTDOWN_FORCED
};
enum shutdown_t {
SHUTDOWN_RUNNING,
SHUTDOWN_GRACEFUL,
SHUTDOWN_FORCED
};
-LIBTEST_INTERNAL_API
-bool is_shutdown();
+namespace libtest {
+
+class SignalThread {
+ sigset_t set;
+ sem_t lock;
+ uint64_t magic_memory;
+ volatile shutdown_t __shutdown;
+ pthread_mutex_t shutdown_mutex;
+ pthread_t thread;
+ sigset_t original_set;
-LIBTEST_INTERNAL_API
-shutdown_t get_shutdown();
+public:
-LIBTEST_INTERNAL_API
-void set_shutdown(shutdown_t arg);
+ SignalThread();
+ ~SignalThread();
+
+ void test();
+ void post();
+ bool setup();
+
+ int wait(int& sig)
+ {
+ return sigwait(&set, &sig);
+ }
+
+ void set_shutdown(shutdown_t arg);
+ bool is_shutdown();
+ shutdown_t get_shutdown();
+};
-LIBTEST_INTERNAL_API
-void setup_signals(void);
+} // namespace libtest