Results for: "to_proc"

Register an event handler p which is called every time a line in file_name is executed.

Example:

Tracer.set_get_line_procs("example.rb", lambda { |line|
  puts "line number executed is #{line}"
})

Invoked by Process::Status.wait in order to wait for a specified process. See that method description for arguments description.

Suggested minimal implementation:

Thread.new do
  Process::Status.wait(pid, flags)
end.value

This hook is optional: if it is not present in the current scheduler, Process::Status.wait will behave as a blocking method.

Expected to returns a Process::Status instance.

No documentation available
No documentation available

Sets the minimum and maximum supported protocol versions. See min_version= and max_version=.

No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available
No documentation available

Stop tracing object allocations.

Note that if ::trace_object_allocations_start is called n-times, then tracing will stop after calling ::trace_object_allocations_stop n-times.

No documentation available

Sets the process title that appears on the ps(1) command. Not necessarily effective on all platforms. No exception will be raised regardless of the result, nor will NotImplementedError be raised even if the platform does not support the feature.

Calling this method does not affect the value of $0.

Process.setproctitle('myapp: worker #%d' % worker_id)

This method first appeared in Ruby 2.1 to serve as a global variable free means to change the process title.

Returns the number of online processors.

The result is intended as the number of processes to use all available processors.

This method is implemented using:

Example:

require 'etc'
p Etc.nprocessors #=> 4

The result might be smaller number than physical cpus especially when ruby process is bound to specific cpus. This is intended for getting better parallel processing.

Example: (Linux)

linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors"  #=> 2

Gets the scheduling priority for specified process, process group, or user. kind indicates the kind of entity to find: one of Process::PRIO_PGRP, Process::PRIO_USER, or Process::PRIO_PROCESS. integer is an id indicating the particular process, process group, or user (an id of 0 means current). Lower priorities are more favorable for scheduling. Not available on all platforms.

Process.getpriority(Process::PRIO_USER, 0)      #=> 19
Process.getpriority(Process::PRIO_PROCESS, 0)   #=> 19

See Process.getpriority.

Process.setpriority(Process::PRIO_USER, 0, 19)      #=> 0
Process.setpriority(Process::PRIO_PROCESS, 0, 19)   #=> 0
Process.getpriority(Process::PRIO_USER, 0)          #=> 19
Process.getpriority(Process::PRIO_PROCESS, 0)       #=> 19

Initializes the supplemental group access list by reading the system group database and using all groups of which the given user is a member. The group with the specified gid is also added to the list. Returns the resulting Array of the gids of all the groups in the supplementary group access list. Not available on all platforms.

Process.groups   #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
Process.initgroups( "mgranger", 30 )   #=> [30, 6, 10, 11]
Process.groups   #=> [30, 6, 10, 11]

Get an Array of the group IDs in the supplemental group access list for this process.

Process.groups   #=> [27, 6, 10, 11]

Note that this method is just a wrapper of getgroups(2). This means that the following characteristics of the result completely depend on your system:

You can make sure to get a sorted unique GID list of the current process by this expression:

Process.groups.uniq.sort

Set the supplemental group access list to the given Array of group IDs.

Process.groups   #=> [0, 1, 2, 3, 4, 6, 10, 11, 20, 26, 27]
Process.groups = [27, 6, 10, 11]   #=> [27, 6, 10, 11]
Process.groups   #=> [27, 6, 10, 11]

Returns the maximum number of gids allowed in the supplemental group access list.

Process.maxgroups   #=> 32

Sets the maximum number of gids allowed in the supplemental group access list.

Returns the cross product of this vector with the others.

Vector[1, 0, 0].cross_product Vector[0, 1, 0]  # => Vector[0, 0, 1]

It is generalized to other dimensions to return a vector perpendicular to the arguments.

Vector[1, 2].cross_product # => Vector[-2, 1]
Vector[1, 0, 0, 0].cross_product(
   Vector[0, 1, 0, 0],
   Vector[0, 0, 1, 0]
)  #=> Vector[0, 0, 0, 1]

Computes and returns or yields all combinations of elements from all the Arrays, including both self and other_arrays.

When no block is given, returns the combinations as an Array of Arrays:

a = [0, 1, 2]
a1 = [3, 4]
a2 = [5, 6]
p = a.product(a1)
p.size # => 6 # a.size * a1.size
p # => [[0, 3], [0, 4], [1, 3], [1, 4], [2, 3], [2, 4]]
p = a.product(a1, a2)
p.size # => 12 # a.size * a1.size * a2.size
p # => [[0, 3, 5], [0, 3, 6], [0, 4, 5], [0, 4, 6], [1, 3, 5], [1, 3, 6], [1, 4, 5], [1, 4, 6], [2, 3, 5], [2, 3, 6], [2, 4, 5], [2, 4, 6]]

If any argument is an empty Array, returns an empty Array.

If no argument is given, returns an Array of 1-element Arrays, each containing an element of self:

a.product # => [[0], [1], [2]]

When a block is given, yields each combination as an Array; returns self:

a.product(a1) {|combination| p combination }

Output:

[0, 3]
[0, 4]
[1, 3]
[1, 4]
[2, 3]
[2, 4]

If any argument is an empty Array, does not call the block:

a.product(a1, a2, []) {|combination| fail 'Cannot happen' }

If no argument is given, yields each element of self as a 1-element Array:

a.product {|combination| p combination }

Output:

[0]
[1]
[2]
Search took: 5ms  ·  Total Results: 1700