Sha256: 3c051b848795db52359ab7df39f6e4a70da72c6755ea2af5e1661488a7331e0d

Contents?: true

Size: 607 Bytes

Versions: 12

Compression:

Stored size: 607 Bytes

Contents

require 'rubygems'
require 'test/unit'

require File.dirname(__FILE__) + "/../lib/mailbox"

class ChannelBasedLogger
  include Mailbox

  def initialize(log_channel)
    register_channel :log_channel, log_channel
  end

  mailslot :channel => :log_channel
  def log(message)
    p "Logging on Thread #{Thread.current.object_id} - #{message}"
  end
end

class ChannelBasedLogExample < Test::Unit::TestCase

  def test_log_example
    channel = JRL::Channel.new
    logger = ChannelBasedLogger.new channel
    p "Current Thread is #{Thread.current.object_id}"
    channel.publish "some log message"
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
mailbox-0.2.7 example/channel_based_log_example.rb
mailbox-0.2.6 example/channel_based_log_example.rb
mailbox-0.2.5 example/channel_based_log_example.rb
mailbox-0.2.4 example/channel_based_log_example.rb
mailbox-0.2.3 example/channel_based_log_example.rb
mailbox-0.2.2 example/channel_based_log_example.rb
mailbox-0.2.1 example/channel_based_log_example.rb
mailbox-0.2.0 example/channel_based_log_example.rb
mailbox-0.1.7 example/channel_based_log_example.rb
mailbox-0.1.6 example/channel_based_log_example.rb
mailbox-0.1.4 example/channel_based_log_example.rb
mailbox-0.1.3 example/channel_based_log_example.rb