Sha256: fd7989b5c7f770483ee2958dcf121608670cc0771a8d42585a3a015db9cc59e3

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 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

11 entries across 11 versions & 1 rubygems

Version Path
aws-crt-0.4.0-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.3.0-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.1-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.2.0-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.9-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.8-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.7-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.6-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.5-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.4-x64-mingw32 lib/aws-crt/io/event_loop_group.rb
aws-crt-0.1.2-x86_64-mingw32 lib/aws-crt/io/event_loop_group.rb