Results for: "Logger"

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:

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’).

Convert source_string and return destination_string.

source_string is assumed as a part of source. i.e. :partial_input=>true is specified internally. finish method should be used last.

ec = Encoding::Converter.new("utf-8", "euc-jp")
puts ec.convert("\u3042").dump     #=> "\xA4\xA2"
puts ec.finish.dump                #=> ""

ec = Encoding::Converter.new("euc-jp", "utf-8")
puts ec.convert("\xA4").dump       #=> ""
puts ec.convert("\xA2").dump       #=> "\xE3\x81\x82"
puts ec.finish.dump                #=> ""

ec = Encoding::Converter.new("utf-8", "iso-2022-jp")
puts ec.convert("\xE3").dump       #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x81").dump       #=> "".force_encoding("ISO-2022-JP")
puts ec.convert("\x82").dump       #=> "\e$B$\"".force_encoding("ISO-2022-JP")
puts ec.finish.dump                #=> "\e(B".force_encoding("ISO-2022-JP")

If a conversion error occur, Encoding::UndefinedConversionError or Encoding::InvalidByteSequenceError is raised. Encoding::Converter#convert doesn’t supply methods to recover or restart from these exceptions. When you want to handle these conversion errors, use Encoding::Converter#primitive_convert.

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

Returns the existing equal key if it exists, otherwise returns nil.

This might be useful for implementing caches, so that only one copy of some object would be used everywhere in the program:

value = {amount: 1, currency: 'USD'}

# Now if we put this object in a cache:
cache = ObjectSpace::WeakKeyMap.new
cache[value] = true

# ...we can always extract from there and use the same object:
copy = cache.getkey({amount: 1, currency: 'USD'})
copy.object_id == value.object_id #=> true

If none is given, returns the resulting hash value of the digest, keeping the digest’s state.

If a string is given, returns the hash value for the given string, resetting the digest to the initial state before and after the process.

Returns the resulting hash value and resets the digest to the initial state.

If none is given, returns the resulting hash value of the digest in a hex-encoded form, keeping the digest’s state.

If a string is given, returns the hash value for the given string in a hex-encoded form, resetting the digest to the initial state before and after the process.

Returns the resulting hash value in a hex-encoded form and resets the digest to the initial state.

If none is given, returns the resulting hash value of the digest in a base64 encoded form, keeping the digest’s state.

If a string is given, returns the hash value for the given string in a base64 encoded form, resetting the digest to the initial state before and after the process.

In either case, the return value is properly padded with ‘=’ and contains no line feeds.

Returns the resulting hash value and resets the digest to the initial state.

Creates an array of handlers for the given libs, can be an instance of Fiddle::Handle, Fiddle::Importer, or will create a new instance of Fiddle::Handle using Fiddle.dlopen

Raises a DLError if the library cannot be loaded.

See Fiddle.dlopen

Creates a global method from the given C signature.

The Fiddle::CompositeHandler instance

Will raise an error if no handlers are open.

If a block is given, it prints out each of the elements encountered. Block parameters are (in that order):

Example

der = File.binread('asn1data.der')
OpenSSL::ASN1.traverse(der) do | depth, offset, header_len, length, constructed, tag_class, tag|
  puts "Depth: #{depth} Offset: #{offset} Length: #{length}"
  puts "Header length: #{header_len} Tag: #{tag} Tag class: #{tag_class} Constructed: #{constructed}"
end

Get the next 8bit byte from ‘ssl`. Returns `nil` on EOF

Reads the next “line” from the stream. Lines are separated by eol. If limit is provided the result will not be longer than the given number of bytes.

eol may be a String or Regexp.

Unlike IO#gets the line read will not be assigned to +$_+.

Unlike IO#gets the separator must be provided if a limit is provided.

Search took: 5ms  ·  Total Results: 2278