Skip to content

Commit

Permalink
Tidy - remove logging statements
Browse files Browse the repository at this point in the history
  • Loading branch information
samaaron committed Oct 15, 2024
1 parent 06fe62a commit ffd5a9a
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 68 deletions.
29 changes: 0 additions & 29 deletions app/server/ruby/lib/sonicpi/lang/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2301,9 +2301,6 @@ def live_loop(name=nil, *args, &block)

start_live_loop = Promise.new
parent_thread = Thread.current
# lg ""
# lg "live_loop creation w/: #{Thread.current.object_id} -> #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
# lg "======================"
mk_live_loop = lambda do
in_thread(name: ll_name, delay: delay, sync: sync_sym, sync_bpm: sync_bpm_sym) do

Expand All @@ -2314,7 +2311,6 @@ def live_loop(name=nil, *args, &block)
else
res = 0
end
lg "LL #{name} - started - [#{Thread.current.object_id}] -> #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
use_random_seed args_h[:seed] if args_h[:seed]

loop do
Expand All @@ -2340,31 +2336,15 @@ def live_loop(name=nil, *args, &block)
old_bus = __system_thread_locals.get :sonic_pi_mod_sound_synth_out_bus
__system_thread_locals.set(:sonic_pi_mod_sound_synth_out_bus, new_bus)
__system_thread_locals.set(:sonic_pi_mod_sound_job_group, new_group)

lg ""
lg "live_loop #{Thread.current.object_id} "
lg " - parent: #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
lg " - sending moved signal"
lg " - moved bus from #{old_bus} -> #{new_bus}"
lg " - move completed ack: #{ack_prom.object_id}"
lg ""
moved_prom.deliver! tracker
lg "....waiting for ack"
ack_prom.get
lg "....got ack"
__system_thread_locals.set_local :sonic_pi_local_spider_thread_moved, new_thread_moved_prom
__system_thread_locals.set_local :sonic_pi_local_spider_thread_moved_ack, new_thread_moved_ack_prom
__system_thread_locals.set_local :sonic_pi_local_live_loop_move_to_bus_and_parent_t, nil
new_job_id = __system_thread_locals(new_parent_t).get(:sonic_pi_spider_job_id)
job_subthread_move_named(Thread.current, new_job_id, ll_name)
__remove_thread_from_parent_subthreads!(Thread.current)
__move_thread_to_new_parent!(Thread.current, new_parent_t)
lg ""
lg "live_loop #{Thread.current.object_id} "
lg " - parent: #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
lg " - moved to bus: #{current_out_bus}"

lg ""
completed_prom.deliver! :moved
end
__live_loop_cue name if __system_thread_locals.get :sonic_pi_local_live_loop_auto_cue
Expand All @@ -2389,7 +2369,6 @@ def live_loop(name=nil, *args, &block)
move_holding_thread_prom = Promise.new
Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "ll swapper and holding thread for #{name} #{st}"
lg "LL[#{Thread.current.object_id}] #{name} - move - [#{st.object_id}] -> #{parent_thread.object_id} - ST:#{Thread.current.object_id}"
completed_prom = Promise.new


Expand All @@ -2399,7 +2378,6 @@ def live_loop(name=nil, *args, &block)

_b, _g, t, p = __system_thread_locals(st).get(:sonic_pi_local_live_loop_move_to_bus_and_parent_t)
if p
lg "CLOBBERING #{t.object_id} #{__system_thread_locals(t).get(:sonic_pi_local_thread_group)} #{p.object_id}"
## another live loop already registered a move, but didn't manage to swap in time - so we're going to clobber it
p.deliver! :clobbered
end
Expand All @@ -2421,8 +2399,6 @@ def live_loop(name=nil, *args, &block)
ct2.kill

if moved_or_clobbered == :moved
lg "LL[#{Thread.current.object_id}] #{name} - moved - [#{st.object_id}] - ST:#{Thread.current.object_id}"

st_joined_or_moved_again = Promise.new
mt1 = Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "ll join waiter for #{name} #{st.object_id} #{__system_thread_locals(st).get(:sonic_pi_local_thread_group)}"
Expand All @@ -2434,17 +2410,12 @@ def live_loop(name=nil, *args, &block)
__system_thread_locals.set_local :sonic_pi_local_thread_group, "ll move waiter for #{name} #{st.object_id} #{__system_thread_locals(st).get(:sonic_pi_local_thread_group)}"

ack_p = __system_thread_locals(st).get(:sonic_pi_local_spider_thread_moved_ack)
lg "LL[#{Thread.current.object_id}] #{name} - waiting for move again - [#{st.object_id}] - ack_p: #{ack_p.object_id}"
ack_p.get
st_joined_or_moved_again.deliver! true, false
end
lg "LL[#{Thread.current.object_id}] #{name} - KA - [#{st.object_id}] -> #{parent_thread.object_id} - ST:#{Thread.current.object_id}"
st_joined_or_moved_again.get
lg "LL[#{Thread.current.object_id}] #{name} - Done - [#{st.object_id}] -> #{parent_thread.object_id} - ST:#{Thread.current.object_id}"
mt1.kill
mt2.kill
else
lg "LL[#{Thread.current.object_id}] #{name} - clobbered - [#{st.object_id}] - ST:#{Thread.current.object_id}"
end
move_holding_thread_prom.deliver! true
end
Expand Down
17 changes: 0 additions & 17 deletions app/server/ruby/lib/sonicpi/lang/sound.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1815,34 +1815,22 @@ def with_fx(fx_name, *args, &block)
kill_delay = args_h[:kill_delay] || 1
end

lg "FX #{fx_name} - waiting #{subthreads.size} - #{new_bus}"

subthreads.map do |st|


Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "wfx subthread waiter for #{fx_name} #{new_bus}"
subthread_completed_or_moved = Promise.new
wt1 = Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "wfx join waiter for #{fx_name} #{new_bus}"
st.join
__system_thread_locals(st).get(:sonic_pi_local_spider_subthread_empty).get
lg " --> FX #{fx_name} - GC Joined - #{new_bus} - ST:#{st.object_id}"
subthread_completed_or_moved.deliver! true
end
wt2 = Thread.new do
__system_thread_locals.set_local :sonic_pi_local_thread_group, "wfx move waiter for #{fx_name} #{new_bus}"
p = __system_thread_locals(st).get(:sonic_pi_local_spider_thread_moved)
lg " --> FX #{fx_name} - GC Wait - #{new_bus} - ST:#{st.object_id} P:#{p.object_id} "
# lg "wfx [#{fx_name}] - waiting for thread moved #{st.class.inspect} - #{st.object_id}"
#
tracker_from_moved_thread = p.get
lg " --> wfx [#{fx_name}] - bus:#{new_bus.id} delivering prom:#{__system_thread_locals(st).get(:sonic_pi_local_spider_thread_moved_ack).object_id}"
__system_thread_locals(st).get(:sonic_pi_local_spider_thread_moved_ack).deliver! true, false
# lg "wfx [#{fx_name}] - waiting on tracker #{tracker.object_id}"
tracker_from_moved_thread.get
# lg "wfx [#{fx_name}] - tracker completed #{tracker.object_id}"
lg " --> FX #{fx_name} - GC Moved - #{new_bus} - #{st.object_id}"
subthread_completed_or_moved.deliver! true
end
subthread_completed_or_moved.get
Expand All @@ -1852,11 +1840,8 @@ def with_fx(fx_name, *args, &block)
end.each do |jt|
jt.join
end
lg "FX #{fx_name} - trk await - #{new_bus} - trk:#{tracker.object_id}"
tracker.block_until_finished
Kernel.sleep(kill_delay)
lg "FX #{fx_name} - completed - #{new_bus}"
lg "FX #{fx_name} - killing - #{new_bus}"
fx_container_group.kill(true)
end

Expand Down Expand Up @@ -1886,8 +1871,6 @@ def with_fx(fx_name, *args, &block)
__system_thread_locals.set(:sonic_pi_mod_sound_synth_out_bus, new_bus)
__system_thread_locals.set_local(:sonic_pi_local_mod_fx_tracker, tracker)

lg "FX #{fx_name} - created - #{new_bus}"

begin
if block.arity == 0
args_h[:reps].times do
Expand Down
15 changes: 0 additions & 15 deletions app/server/ruby/lib/sonicpi/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,6 @@ def __spider_eval(code, info={})
Thread.current.priority = 20
begin
num_running_jobs = register_job!(id, Thread.current)
lg "registering job #{id} with #{num_running_jobs} running jobs"
__system_thread_locals.set_local :sonic_pi_local_thread_group, "job-#{id}"
__system_thread_locals.set_local :sonic_pi_spider_thread_id_path, ThreadId.new(id)
__system_thread_locals.set_local :sonic_pi_spider_num_threads_spawned, 0
Expand All @@ -954,16 +953,8 @@ def __spider_eval(code, info={})
end
__info "Starting run #{id}" unless silent
code = PreParser.preparse(code, SonicPi::Lang::Core.vec_fns)
lg "\n\n"
lg " EVAL #{Thread.current.object_id} - NThreads: #{Thread.list.size}"
lg " - n-threads: #{Thread.list.size}"
Thread.list.sort_by(&:object_id).map{|t| lg " [#{t.object_id}] -> #{__system_thread_locals(t).get(:sonic_pi_local_thread_group)}"}

job_in_thread = __in_thread seed: 0 do
lg " spider eval #{Thread.current.object_id} -> #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
STDOUT.flush
with_fx :level, amp: 1 do

eval(code, nil, info[:workspace], firstline)
end
end
Expand Down Expand Up @@ -1164,12 +1155,7 @@ def __in_thread(*opts, &block)
__system_thread_locals.set_local(:sonic_pi_local_spider_thread_moved, Promise.new)
__system_thread_locals.set_local(:sonic_pi_local_spider_thread_move_mut, Mutex.new)

# lg "\n====> in-thread"
# lg "New thread #{Thread.current.object_id} as child of #{parent_t.object_id}"
STDOUT.flush
__system_thread_locals.set_local(:sonic_pi_local_parent_thread, parent_t)
# lg "New thread #{Thread.current.object_id} -> #{__system_thread_locals.get(:sonic_pi_local_parent_thread).object_id}"
STDOUT.flush

# Wait for parent to deliver promise. Throws an exception if
# parent dies before the promise is delivered, thus stopping
Expand Down Expand Up @@ -1348,7 +1334,6 @@ def job_subthread_add_unmutexed(job_id, t, name=nil)
end

def job_subthread_move_named_unmutexed(t, new_job_id, name)
lg "Moving thread #{name} to job #{new_job_id}"
named_thread = @named_subthreads[name]
raise unless named_thread
raise unless named_thread.thread == t
Expand Down
7 changes: 0 additions & 7 deletions app/server/ruby/lib/sonicpi/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,6 @@ def fetch_url(url, anonymous_uuid=true)

end

def lg(s)
# time = Time.now
# formatted_time = time.strftime("%H:%M:%S") + ".#{time.strftime("%L")}"
# Kernel.puts "[#{formatted_time}] #{s}"
# STDOUT.flush
end

def log_raw(s)
if @@log_file
@@log_file.write("[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] #{s}")
Expand Down

0 comments on commit ffd5a9a

Please sign in to comment.