Class: CurlFFI::Multi
- Inherits:
-
Object
- Object
- CurlFFI::Multi
- Defined in:
- lib/curl_ffi/multi.rb
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
-
#running ⇒ Object
readonly
Returns the value of attribute running.
Instance Method Summary collapse
- #add_handle(easy) ⇒ Object
- #info_read_all ⇒ Object
- #info_read_next ⇒ Object
-
#initialize ⇒ Multi
constructor
A new instance of Multi.
- #perform ⇒ Object
- #remove_handle(easy) ⇒ Object
- #setopt(option, param) ⇒ Object
- #socket_action(sockfd, ev_bitmask = 0) ⇒ Object
- #timeout ⇒ Object
Constructor Details
Instance Attribute Details
#pointer ⇒ Object (readonly)
Returns the value of attribute pointer.
5 6 7 |
# File 'lib/curl_ffi/multi.rb', line 5 def pointer @pointer end |
#running ⇒ Object (readonly)
Returns the value of attribute running.
5 6 7 |
# File 'lib/curl_ffi/multi.rb', line 5 def running @running end |
Instance Method Details
#add_handle(easy) ⇒ Object
TODO:
handle return code
15 16 17 18 |
# File 'lib/curl_ffi/multi.rb', line 15 def add_handle(easy) CurlFFI.multi_add_handle(@pointer, easy.pointer) @handles << easy # Save the handle so it won't be gc'ed end |
#info_read_all ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/curl_ffi/multi.rb', line 30 def info_read_all() = [] while = info_read_next << end end |
#info_read_next ⇒ Object
38 39 40 41 42 43 |
# File 'lib/curl_ffi/multi.rb', line 38 def info_read_next() int_pointer = FFI::MemoryPointer.new(:int) = CurlFFI.multi_info_read(@pointer, int_pointer) @messages_in_queue = int_pointer.read_int .null? ? nil : CurlFFI::Message.new() end |
#perform ⇒ Object
53 54 55 56 57 58 |
# File 'lib/curl_ffi/multi.rb', line 53 def perform() int_pointer = FFI::MemoryPointer.new(:int) result = CurlFFI.multi_perform(@pointer, int_pointer) @running = int_pointer.read_int result end |
#remove_handle(easy) ⇒ Object
TODO:
handle return code
21 22 23 24 |
# File 'lib/curl_ffi/multi.rb', line 21 def remove_handle(easy) CurlFFI.multi_remove_handle(@pointer, easy.pointer) @handles.delete(easy) # Save the handle so it won't be gc'ed end |
#setopt(option, param) ⇒ Object
26 27 28 |
# File 'lib/curl_ffi/multi.rb', line 26 def setopt(option, param) CurlFFI.multi_setopt(@pointer, option, param) end |
#socket_action(sockfd, ev_bitmask = 0) ⇒ Object
TODO:
handle return code
46 47 48 49 50 51 |
# File 'lib/curl_ffi/multi.rb', line 46 def socket_action(sockfd, ev_bitmask = 0) int_pointer = FFI::MemoryPointer.new(:int) result = CurlFFI.multi_socket_action(@pointer, sockfd, ev_bitmask, int_pointer) @running = int_pointer.read_int result end |
#timeout ⇒ Object
60 61 62 63 64 |
# File 'lib/curl_ffi/multi.rb', line 60 def timeout long_pointer = FFI::MemoryPointer.new(:long) result = CurlFFI.multi_timeout(@pointer, long_pointer) long_pointer.read_long end |