Returns the number of threads waiting on the queue.
Returns the number of threads waiting on the queue.
Removes tracing for the specified command on the given global variable and returns nil
. If no command is specified, removes all tracing for that variable and returns an array containing the commands actually removed.
Returns a pretty printed object as a string.
In order to use this method you must first require the PP
module:
require 'pp'
See the PP
module for more information.
Ruby tries to load the library named string relative to the requiring file’s path. If the file’s path cannot be determined a LoadError
is raised. If a file is loaded true
is returned and false otherwise.
Iterates the given block for each array of consecutive <n> elements. If no block is given, returns an enumerator.
e.g.:
(1..10).each_cons(3) { |a| p a } # outputs below [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 6] [5, 6, 7] [6, 7, 8] [7, 8, 9] [8, 9, 10]
Counts symbols for each Symbol
type.
This method is only for MRI developers interested in performance and memory usage of Ruby programs.
If the optional argument, result_hash, is given, it is overwritten and returned. This is intended to avoid probe effect.
Note: The contents of the returned hash is implementation defined. It may be changed in future.
This method is only expected to work with C Ruby.
On this version of MRI, they have 3 types of Symbols (and 1 total counts).
* mortal_dynamic_symbol: GC target symbols (collected by GC) * immortal_dynamic_symbol: Immortal symbols promoted from dynamic symbols (do not collected by GC) * immortal_static_symbol: Immortal symbols (do not collected by GC) * immortal_symbol: total immortal symbols (immortal_dynamic_symbol+immortal_static_symbol)
Calls the block once for each living, nonimmediate object in this Ruby process. If module is specified, calls the block for only those classes or modules that match (or are a subclass of) module. Returns the number of objects found. Immediate objects (Fixnum
s, Symbol
s true
, false
, and nil
) are never returned. In the example below, each_object
returns both the numbers we defined and several constants defined in the Math
module.
If no block is given, an enumerator is returned instead.
a = 102.7 b = 95 # Won't be returned c = 12345678987654321 count = ObjectSpace.each_object(Numeric) {|x| p x } puts "Total count: #{count}"
produces:
12345678987654321 102.7 2.71828182845905 3.14159265358979 2.22044604925031e-16 1.7976931348623157e+308 2.2250738585072e-308 Total count: 7
Removes all finalizers for obj.
Dump Ruby object
to a JSON
string.
Adds a post-installs hook that will be passed a Gem::DependencyInstaller
and a list of installed specifications when Gem::DependencyInstaller#install
is complete
Adds a post-uninstall hook that will be passed a Gem::Uninstaller
instance and the spec that was uninstalled when Gem::Uninstaller#uninstall
is called
Adds a pre-uninstall hook that will be passed an Gem::Uninstaller
instance and the spec that will be uninstalled when Gem::Uninstaller#uninstall
is called
Returns whether or not the constant const
is defined. You may optionally pass the type
of const
as [const, type]
, such as:
have_const(%w[PTHREAD_MUTEX_INITIALIZER pthread_mutex_t], "pthread.h")
You may also pass additional headers
to check against in addition to the common header files, and additional flags to opt
which are then passed along to the compiler.
If found, a macro is passed as a preprocessor constant to the compiler using the type name, in uppercase, prepended with HAVE_CONST_
.
For example, if have_const('foo')
returned true, then the HAVE_CONST_FOO
preprocessor macro would be passed to the compiler.
Tests for the presence of a --with-
config or --without-
config option. Returns true
if the with option is given, false
if the without option is given, and the default value otherwise.
This can be useful for adding custom definitions, such as debug information.
Example:
if with_config("debug") $defs.push("-DOSSL_DEBUG") unless $defs.include? "-DOSSL_DEBUG" end
Sets a target
name that the user can then use to configure various “with” options with on the command line by using that name. For example, if the target is set to “foo”, then the user could use the --with-foo-dir=prefix
, --with-foo-include=dir
and --with-foo-lib=dir
command line options to tell where to search for header/library files.
You may pass along additional parameters to specify default values. If one is given it is taken as default prefix
, and if two are given they are taken as “include” and “lib” defaults in that order.
In any case, the return value will be an array of determined “include” and “lib” directories, either of which can be nil if no corresponding command line option is given when no default value is specified.
Note that dir_config
only adds to the list of places to search for libraries and include files. It does not link the libraries into your application.
Returns compile/link information about an installed library in a tuple of [cflags, ldflags, libs]
, by using the command found first in the following commands:
If --with-{pkg}-config={command}
is given via command line option: {command} {option}
{pkg}-config {option}
pkg-config {option} {pkg}
Where {option} is, for instance, --cflags
.
The values obtained are appended to +$CFLAGS+, +$LDFLAGS+ and +$libs+.
If an option
argument is given, the config command is invoked with the option and a stripped output string is returned without modifying any of the global values mentioned above.
Creates a new MonitorMixin::ConditionVariable
associated with the receiver.
Return the number of observers associated with this object.
Notify observers of a change in state if this object’s changed state is true
.
This will invoke the method named in add_observer
, passing *arg
. The changed state is then set to false
.
*arg
Any arguments to pass to the observers.