Sha256: 9bd333d4299cb2afd79a1067836ae47c73f12168d5a65c7059a8f8f2def1277f

Contents?: true

Size: 973 Bytes

Versions: 11

Compression:

Stored size: 973 Bytes

Contents

require 'asir/transport/local'
require 'thread'

module ASIR
  class Transport
    # !SLIDE
    # Thread Transport
    #
    # Send one-way Message to a Thread.
    class Thread < Local
      # Any object that responds to .new(&blk).
      # Defaults to ::Thread.
      attr_accessor :thread_class

      # Callback: call(self, MessageState, thr).
      attr_accessor :after_thread_new

      def initialize *args
        @thread_class = ::Thread
        @one_way = true; super
      end

      def _send_message state
        thr = thread_class.new do
          super
          send_result(state)
        end
        state.in_stream = thr
        @after_thread_new.call(self, state, thr) if @after_thread_new
        thr
      end

      # one-way; no Result
      def _receive_result state
      end

      # one-way; no Result
      def _send_result state
      end

      # one-may; no Result
      def receive_result state
      end
    end
    # !SLIDE END
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
asir-1.2.11 lib/asir/transport/thread.rb
asir-1.2.10 lib/asir/transport/thread.rb
asir-1.2.9 lib/asir/transport/thread.rb
asir-1.2.8 lib/asir/transport/thread.rb
asir-1.2.7 lib/asir/transport/thread.rb
asir-1.2.6 lib/asir/transport/thread.rb
asir-1.2.5 lib/asir/transport/thread.rb
asir-1.2.3 lib/asir/transport/thread.rb
asir-1.2.2 lib/asir/transport/thread.rb
asir-1.2.1 lib/asir/transport/thread.rb
asir-1.2.0 lib/asir/transport/thread.rb