Module: Chan
- Defined in:
- lib/xchan.rb,
lib/xchan/version.rb,
lib/xchan/tempfile.rb
Defined Under Namespace
Classes: Bytes, Counter, NullLock, UNIXSocket
Constant Summary collapse
- WaitReadable =
Class.new(IO::EAGAINWaitReadable)
- WaitWritable =
Class.new(IO::EAGAINWaitWritable)
- WaitLockable =
Class.new(Errno::EWOULDBLOCK)
- Pure =
Coerces an object to a string for a channel communicating in raw strings (in other words: without serialization)
Class.new do def self.dump(str) = str.to_s def self.load(str) = str.to_s end
- VERSION =
"0.18.0"
Class Method Summary collapse
-
.temporary_file(basename, tmpdir: Dir.tmpdir) ⇒ Chan::Tempfile
Returns an unlinked Chan::Tempfile object that can be read from, and written to by the process that created it, inclusive of its child processes, but not of processes other than that.
-
.serializers ⇒ Hash<Symbol, Proc>
Returns the default serializers.
-
.locks ⇒ Hash<Symbol, Proc>
Returns the default locks.
Class Method Details
.temporary_file(basename, tmpdir: Dir.tmpdir) ⇒ Chan::Tempfile
Returns an unlinked Chan::Tempfile object that can be read from, and written to by the process that created it, inclusive of its child processes, but not of processes other than that.
40 41 42 |
# File 'lib/xchan.rb', line 40 def self.temporary_file(basename, tmpdir: Dir.tmpdir) Chan::Tempfile.new(basename, tmpdir, perm: 0).tap(&:unlink) end |
.serializers ⇒ Hash<Symbol, Proc>
Returns the default serializers
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/xchan.rb', line 47 def self.serializers { pure: lambda { Pure }, marshal: lambda { Marshal }, json: lambda { require "json" unless defined?(JSON) JSON }, yaml: lambda { require "yaml" unless defined?(YAML) YAML } } end |
.locks ⇒ Hash<Symbol, Proc>
Returns the default locks
65 66 67 68 69 70 |
# File 'lib/xchan.rb', line 65 def self.locks { null: lambda { |_tmpdir| Chan::NullLock }, file: lambda { |tmpdir| Lock::File.new Chan.temporary_file(%w[xchan lock], tmpdir:) } } end |