Class: Mixboard::Mixer

Inherits:
Object
  • Object
show all
Includes:
UtilityFunctions, Singleton
Defined in:
app/mixer/mixboard/mixer.rb

Overview

The Mixer is a singleton class that actually does the routing of signals.

Constant Summary collapse

CONFIGURATION_MUTEX =
Mutex.new

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from UtilityFunctions

#assert_non_nil_of_type, #assert_type, #declare_abstract_method_body, #method_not_implemented_error

Instance Attribute Details

#map_refresh_timeoutObject



40
41
42
# File 'app/mixer/mixboard/mixer.rb', line 40

def map_refresh_timeout
  @map_refresh_timeout ||= 30
end

Instance Method Details

#accept(signal, source) ⇒ Object

Accept a signal from a source to route it to the correct channels

Parameters:



16
17
18
19
20
21
22
# File 'app/mixer/mixboard/mixer.rb', line 16

def accept(signal, source)
  assert_non_nil_of_type(signal, Signal)
  assert_non_nil_of_type(source, Source)
  (channel_map[source.class] || []).each do |channel|
    channel.accept(signal)
  end
end

#clear_configurationObject



36
37
38
# File 'app/mixer/mixboard/mixer.rb', line 36

def clear_configuration
  @configuration = nil
end

#configure(&block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'app/mixer/mixboard/mixer.rb', line 24

def configure(&block)
  CONFIGURATION_MUTEX.synchronize do
    return unless @configuration.nil?

    c = Mixboard::Configuration.new
    block.call(c) if block_given?
    c.setup_channel_map
    @last_map_refresh = 0
    @configuration = c
  end
end

#dynamic_channel_storeObject



44
45
46
# File 'app/mixer/mixboard/mixer.rb', line 44

def dynamic_channel_store
  configuration.dynamic_channel_store
end