Class: Ethon::Multi

Inherits:
Object
  • Object
show all
Includes:
Ethon::Multies::Operations, Ethon::Multies::Stack
Defined in:
lib/ethon/multi.rb

Overview

This class represents libcurl multi.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ethon::Multies::Operations

#check, #get_timeout, #init_vars, #ongoing?, #perform, #reset_fds, #run, #running_count, #set_fds, #trigger

Methods included from Ethon::Multies::Stack

#add, #delete, #easy_handles

Constructor Details

#initializeMulti

Create a new multi. Initialize curl in case it didn’t happen before.



30
31
32
33
34
# File 'lib/ethon/multi.rb', line 30

def initialize
  Curl.init
  ObjectSpace.define_finalizer(self, self.class.finalizer(self))
  init_vars
end

Class Method Details

.finalizer(multi) ⇒ Object

Frees the libcurl multi handle.

Examples:

Free multi.

Multi.finalizer(multi)

Parameters:

  • multi (Multi)

    The multi to free.



19
20
21
22
23
# File 'lib/ethon/multi.rb', line 19

def finalizer(multi)
  proc {
    Curl.multi_cleanup(multi.handle)
  }
end

Instance Method Details

#handle::FFI::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.



43
44
45
# File 'lib/ethon/multi.rb', line 43

def handle
  @handle ||= Curl.multi_init
end