Module: Ethon::Multi::Operations

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

Overview

This module contains logic to run a multi.

Constant Summary collapse

STARTED_MULTI =
"ETHON: started MULTI"
PERFORMED_MULTI =
"ETHON: performed 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.


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

def handle
  @handle ||= FFI::AutoPointer.new(Curl.multi_init, Curl.method(:multi_cleanup))
end

#init_varsvoid

This method returns an undefined value.

Initialize variables.

Examples:

Initialize variables.

multi.init_vars

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

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)

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

def perform
  Ethon.logger.debug(STARTED_MULTI)
  while ongoing?
    run
    timeout = get_timeout
    next if timeout == 0
    reset_fds
    set_fds(timeout)
  end
  Ethon.logger.debug(PERFORMED_MULTI)
  nil
end

#preparenil

Deprecated.

It is no longer necessary to call prepare.

Prepare multi.

Examples:

Prepare multi.

multi.prepare

Returns:

  • (nil)

61
62
63
64
65
66
67
# File 'lib/ethon/multi/operations.rb', line 61

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