Module: Ethon::Multi::Operations

Included in:
Ethon::Multi
Defined in:
lib/ethon/multi/operations.rb

Overview

This module contains logic to run a multi.

Instance Method Summary collapse

Instance Method Details

#handleFFI::Pointer

Return the multi handle. Inititialize multi handle, in case it didn’t happened already.

Examples:

Return multi handle.

multi.handle

Returns:

  • (FFI::Pointer)

    The multi handle.



14
15
16
# File 'lib/ethon/multi/operations.rb', line 14

def handle
  @handle ||= Curl.multi_init
end

#init_varsvoid

This method returns an undefined value.

Initialize variables.

Examples:

Initialize variables.

multi.init_vars


24
25
26
27
28
29
30
31
# File 'lib/ethon/multi/operations.rb', line 24

def init_vars
  @timeout = ::FFI::MemoryPointer.new(:long)
  @timeval = Curl::Timeval.new
  @fd_read = Curl::FDSet.new
  @fd_write = Curl::FDSet.new
  @fd_excep = Curl::FDSet.new
  @max_fd = ::FFI::MemoryPointer.new(:int)
end

#performnil

Perform multi.

Examples:

Perform multi.

multi.perform

Returns:

  • (nil)


41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/ethon/multi/operations.rb', line 41

def perform
  Ethon.logger.debug("ETHON: started MULTI")
  while ongoing?
    run
    timeout = get_timeout
    next if timeout == 0
    reset_fds
    set_fds(timeout)
  end
  Ethon.logger.debug("ETHON: performed MULTI")
  nil
end

#preparenil

Deprecated.

It is no longer necessary to call prepare.

Prepare multi.

Examples:

Prepare multi.

multi.prepare

Returns:

  • (nil)


64
65
66
67
68
69
70
# File 'lib/ethon/multi/operations.rb', line 64

def prepare
  Ethon.logger.warn(
    "ETHON: It is no longer necessay to call "+
    "Multi#prepare. Its going to be removed "+
    "in future versions."
  )
end