Returns the parser to be used.
Unless a URI::Parser
is defined, DEFAULT_PARSER is used.
Sets userinfo, argument is string like ‘name:pass’.
v
Public setter for the user
component (with validation).
See also URI::Generic.check_user
.
require 'uri' uri = URI.parse("http://john:S3nsit1ve@my.example.com") uri.user = "sam" uri.to_s #=> "http://sam:V3ry_S3nsit1ve@my.example.com"
Returns the userinfo, either as ‘user’ or ‘user:password’.
Returns the user component (without URI
decoding).
v
Public setter for the query component v
.
require 'uri' uri = URI.parse("http://my.example.com/?id=25") uri.query = "id=1" uri.to_s #=> "http://my.example.com/?id=1"
Returns true if URI
is hierarchical.
URI
has components listed in order of decreasing significance from left to right, see RFC3986 tools.ietf.org/html/rfc3986 1.2.3.
require 'uri' uri = URI.parse("http://my.example.com/") uri.hierarchical? #=> true uri = URI.parse("mailto:joe@example.com") uri.hierarchical? #=> false
Attempts to parse other URI
oth
, returns [parsed_oth, self].
require 'uri' uri = URI.parse("http://my.example.com") uri.coerce("http://foo.com") #=> [#<URI::HTTP http://foo.com>, #<URI::HTTP http://my.example.com>]
Returns filter.
Setter for filter val
.
Setter for headers v
.
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.
Returns the number of the signal that caused the process to terminate or nil
if the process was not terminated by an uncaught signal.
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.
Invoked by methods like Thread.join
, and by Mutex, to signify that current Fiber
is blocked until further notice (e.g. unblock
) or until timeout
has elapsed.
blocker
is what we are waiting on, informational only (for debugging and logging). There are no guarantee about its value.
Expected to return boolean, specifying whether the blocking operation was successful or not.
Invoked to wake up Fiber
previously blocked with block
(for example, Mutex#lock calls block
and Mutex#unlock calls unblock
). The scheduler should use the fiber
parameter to understand which fiber is unblocked.
blocker
is what was awaited for, but it is informational only (for debugging and logging), and it is not guaranteed to be the same value as the blocker
for block
.
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
Returns true
if this lock is currently held by some thread.
Attempts to grab the lock and waits if it isn’t available. Raises ThreadError
if mutex
was locked by the current thread.
Releases the lock. Raises ThreadError
if mutex
wasn’t locked by the current thread.
Closes the queue. A closed queue cannot be re-opened.
After the call to close completes, the following are true:
closed?
will return true
close
will be ignored.
calling enq/push/<< will raise a ClosedQueueError
.
when empty?
is false, calling deq/pop/shift will return an object from the queue as usual.
when empty?
is true, deq(false) will not suspend the thread and will return nil. deq(true) will raise a ThreadError
.
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.
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’).