diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-18 10:28:18 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-18 10:28:18 +0000 |
commit | ab067831e707b191d6dfdcd01de1f1d85fc90d05 (patch) | |
tree | b02861eb1521fb325ee4e1d91e1a194ca73e7a9e /lib/yahns/sigevent_pipe.rb | |
download | yahns-ab067831e707b191d6dfdcd01de1f1d85fc90d05.tar.gz |
Diffstat (limited to 'lib/yahns/sigevent_pipe.rb')
-rw-r--r-- | lib/yahns/sigevent_pipe.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/yahns/sigevent_pipe.rb b/lib/yahns/sigevent_pipe.rb new file mode 100644 index 0000000..6e1be53 --- /dev/null +++ b/lib/yahns/sigevent_pipe.rb @@ -0,0 +1,29 @@ +# -*- encoding: binary -*- +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +class Yahns::Sigevent # :nodoc: + attr_reader :to_io + def initialize + @to_io, @wr = Kgio::Pipe.new + end + + def kgio_wait_readable + @to_io.kgio_wait_readable + end + + def sev_signal + @wr.kgio_write(".") + end + + def yahns_step + # 11 byte strings -> no malloc on YARV + while String === @to_io.kgio_tryread(11) + end + :wait_readable + end + + def close + @to_io.close + @wr.close + end +end |