Sha256: bfb79be639c6d09d484e6cfa94d933cda58f2b65c86376d0783532249f55869b

Contents?: true

Size: 1020 Bytes

Versions: 2

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

module Aws
  module Crt
    # High level Ruby abstractions for CRT IO functionality
    module IO
      # A collection of event-loops.
      # An event-loop is a thread for doing async work, such as I/O.
      # Classes that need to do async work will ask the EventLoopGroup
      # for an event-loop to use.
      class EventLoopGroup
        include Aws::Crt::ManagedNative
        native_destroy Aws::Crt::Native.method(:event_loop_group_release)

        def initialize(max_threads = nil)
          unless max_threads.nil? ||
                 (max_threads.is_a?(Integer) && max_threads.positive?)
            raise ArgumentError, 'max_threads must be nil or positive Integer'
          end

          # Ruby uses nil to request default values, native code uses 0
          max_threads = 0 if max_threads.nil?

          manage_native do
            Aws::Crt::Native.event_loop_group_new(max_threads)
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aws-crt-0.1.1.pre-x64-mingw32 lib/aws-crt/io.rb
aws-crt-0.1.0.pre-x64-mingw32 lib/aws-crt/io.rb