Results for: "OptionParser"

Setter for filter val.

Returns a Hash (not a DBM database) created by using each value in the database as a key, with the corresponding key as its value.

Note that all values in the hash will be Strings, but the keys will be actual objects.

If a block is provided, returns a new array containing [key, value] pairs for which the block returns true.

Otherwise, same as values_at

Returns true if this process is stopped, and if the corresponding wait call had the Process::WUNTRACED flag set, false otherwise.

Returns the number of the signal that caused the process to stop, or nil if the process is not stopped.

Returns the number of the signal that caused the process to terminate or nil if the process was not terminated by an uncaught signal.

No documentation available

Send a message to a port to be accepted by port.receive.

port = Ractor::Port.new
r = Ractor.new do
  r.send 'message'
end
value = port.receive
puts "Received #{value}"
# Prints: "Received: message"

The method is non-blocking (will return immediately even if the ractor is not ready to receive anything):

port = Ractor::Port.new
r = Ractor.new(port) do |port|
  port.send 'test'}
  puts "Sent successfully"
  # Prints: "Sent successfully" immediately
end

An attempt to send to a port which already closed its execution will raise Ractor::ClosedError.

r = Ractor.new {Ractor::Port.new}
r.join
p r
# "#<Ractor:#6 (irb):23 terminated>"
port = r.value
port.send('test') # raise Ractor::ClosedError

If the obj is unshareable, by default it will be copied into the receiving ractor by deep cloning.

If the object is shareable, it only send a reference to the object without cloning.

Close the port. On the closed port, sending is not prohibited. Receiving is also not allowed if there is no sent messages arrived before closing.

port = Ractor::Port.new
Ractor.new port do |port|
  port.sned 1 # OK
  port.send 2 # OK
  port.close
  port.send 3 # raise Ractor::ClosedError
end

port.receive #=> 1
port.receive #=> 2
port.receive #=> raise Ractor::ClosedError

Now, only a Ractor which creates the port is allowed to close ports.

port = Ractor::Port.new
Ractor.new port do |port|
  port.close #=> closing port by other ractors is not allowed (Ractor::Error)
end.join

Return the port is closed or not.

Called when the current thread exits. The scheduler is expected to implement this method in order to allow all waiting fibers to finalize their execution.

The suggested pattern is to implement the main event loop in the close method.

Implementation of the Fiber.schedule. The method is expected to immediately run the given block of code in a separate non-blocking fiber, and to return that Fiber.

Minimal suggested implementation is:

def fiber(&block)
  fiber = Fiber.new(blocking: false, &block)
  fiber.resume
  fiber
end

Obtains a lock, runs the block, and releases the lock when the block completes. See the example under Thread::Mutex.

Closes the queue. A closed queue cannot be re-opened.

After the call to close completes, the following are true:

ClosedQueueError is inherited from StopIteration, so that you can break loop block.

Example:

q = Thread::Queue.new
Thread.new{
  while e = q.deq # wait for nil to break loop
    # ...
  end
}
q.close

Returns true if the queue is closed.

Returns true if the queue is empty.

Removes all objects from the queue.

Retrieves data from the queue.

If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If non_block is true, the thread isn’t suspended, and ThreadError is raised.

If timeout seconds have passed and no data is available nil is returned. If timeout is 0 it returns immediately.

Similar to Thread::Queue#close.

The difference is behavior with waiting enqueuing threads.

If there are waiting enqueuing threads, they are interrupted by raising ClosedQueueError(‘queue closed’).

Returns true if the queue is empty.

Removes all objects from the queue.

Retrieves data from the queue.

If the queue is empty, the calling thread is suspended until data is pushed onto the queue. If non_block is true, the thread isn’t suspended, and ThreadError is raised.

If timeout seconds have passed and no data is available nil is returned. If timeout is 0 it returns immediately.

Returns true if key is a key in self, otherwise false.

Removes all map entries; returns self.

Returns URL-escaped string following RFC 3986.

Search took: 5ms  ·  Total Results: 3694