Sha256: 66ce8b0a72fbdf3a2ef1efb18a4485c9e8e165a033a5968683cd923c3861da9d

Contents?: true

Size: 1.61 KB

Versions: 64

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

module Aws
  module Crt
    # High level Ruby abstractions for CRT IO functionality
    module IO
      # Options for an EventLoopGroup
      class EventLoopGroupOptions
        include Aws::Crt::ManagedNative
        native_destroy Aws::Crt::Native.method(
          :event_loop_group_options_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_options_new
          end

          Aws::Crt::Native.event_loop_group_options_set_max_threads(@native,
                                                                    max_threads)
        end
      end

      # 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)
          @options = EventLoopGroupOptions.new(max_threads)

          manage_native do
            Aws::Crt::Native.event_loop_group_new(@options.native)
          end
          Aws::Crt::Native.event_loop_group_acquire(@native)
        end
      end
    end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
aws-crt-0.4.0-x86_64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.4.0-x86_64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.4.0-universal-java lib/aws-crt/io/event_loop_group.rb
aws-crt-0.4.0-arm64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.4.0-aarch64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.4.0 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-x86_64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-x86_64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-universal-java lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-arm64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-aarch64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-aarch64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-arm64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-universal-java lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-x86_64-darwin lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-x86_64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.0-x86_64-linux lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.0-x86_64-darwin lib/aws-crt/io/event_loop_group.rb