summaryrefslogtreecommitdiff
path: root/src/signaler.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/signaler.hpp')
-rw-r--r--src/signaler.hpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/signaler.hpp b/src/signaler.hpp
index c289490..20c2c36 100644
--- a/src/signaler.hpp
+++ b/src/signaler.hpp
@@ -31,32 +31,30 @@ namespace xs
// given moment. Attempt to send a signal before receiving the previous
// one will result in undefined behaviour.
- class signaler_t
- {
- public:
+ typedef struct {
+ fd_t w;
+ fd_t r;
+ } signaler_t;
- signaler_t ();
- ~signaler_t ();
+ // Initialise the signaler.
+ int signaler_init (signaler_t *self_);
- fd_t get_fd ();
- void send ();
- int wait (int timeout_);
- void recv ();
-
- private:
+ // Destroy the signaler.
+ void signaler_close (signaler_t *self_);
- // Creates a pair of filedescriptors that will be used
- // to pass the signals.
- static int make_fdpair (fd_t *r_, fd_t *w_);
+ // Return file decriptor that you can poll on to get notified when
+ // signal is sent.
+ fd_t signaler_fd (signaler_t *self_);
- // Underlying write & read file descriptor.
- fd_t w;
- fd_t r;
+ // Send a signal.
+ void signaler_send (signaler_t *self_);
+
+ // Wait for a signal. up to timout_ milliseconds.
+ // The signale is *not* consumed by this function.
+ int signaler_wait (signaler_t *self_, int timeout_);
- // Disable copying of signaler_t object.
- signaler_t (const signaler_t&);
- const signaler_t &operator = (const signaler_t&);
- };
+ // Wait for and consume a signal.
+ void signaler_recv (signaler_t *self_);
}