Skip to content

Commit 9cb1c61

Browse files
committed
Core - remove unecessary caching of last sync event
This appears to have been an optimisation that no longer seems to make sense.
1 parent 9c1f211 commit 9cb1c61

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

app/server/ruby/lib/sonicpi/lang/core.rb

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,8 +4189,6 @@ def current_sched_ahead_time
41894189

41904190
def sleep(beats)
41914191
__system_thread_locals.set_local(:sonic_pi_spider_time_state_cache, [])
4192-
__system_thread_locals.set_local(:sonic_pi_local_last_sync, nil)
4193-
41944192

41954193
# Schedule messages
41964194
__schedule_delayed_blocks_and_messages!
@@ -4330,12 +4328,11 @@ def sync_event(*args)
43304328
k = params[0]
43314329

43324330
__system_thread_locals.set_local(:sonic_pi_spider_time_state_cache, [])
4333-
# TODO: need to add this
4331+
43344332
bpm_sync = truthy?(opts[:bpm_sync])
43354333
arg_matcher = opts[:arg_matcher]
43364334

43374335
cue_id = __sync_path(k)
4338-
last_sync = __system_thread_locals.get(:sonic_pi_local_last_sync, nil)
43394336

43404337
__system_thread_locals.set_local :sonic_pi_local_control_deltas, {}
43414338

@@ -4345,27 +4342,16 @@ def sync_event(*args)
43454342

43464343
__schedule_delayed_blocks_and_messages!
43474344

4348-
if last_sync
4349-
t = last_sync.time
4350-
i = last_sync.thread_id
4351-
p = last_sync.priority
4352-
d = last_sync.delta
4353-
b = last_sync.beat
4354-
m = last_sync.bpm
4355-
else
4356-
# TODO insert priority and delta values here:
4357-
t = current_time
4358-
p = __system_thread_locals.get(:sonic_pi_spider_thread_priority, -100)
4359-
i = __current_thread_id
4360-
d = __system_thread_locals.get(:sonic_pi_spider_thread_delta, 0)
4361-
b = current_beat
4362-
m = current_bpm
4363-
end
4345+
t = current_time
4346+
p = __system_thread_locals.get(:sonic_pi_spider_thread_priority, -100)
4347+
i = __current_thread_id
4348+
d = __system_thread_locals.get(:sonic_pi_spider_thread_delta, 0)
4349+
b = current_beat
4350+
m = current_bpm_mode
43644351

43654352
se = @event_history.sync(t, p, i, d, b, m, cue_id, arg_matcher)
43664353

43674354
__system_thread_locals.set(:sonic_pi_spider_synced, true)
4368-
__system_thread_locals.set_local :sonic_pi_local_last_sync, se
43694355

43704356
if bpm_sync
43714357
raise StandardError, "Incorrect bpm value. Expecting either :link or a number such as 120" unless ((se.bpm == :link) || se.bpm.is_a?(Numeric))
@@ -4384,7 +4370,6 @@ def sync_event(*args)
43844370
__delayed_highlight2_message "synced #{cue_id.inspect} " + run_info
43854371
end
43864372
end
4387-
__system_thread_locals.set_local :sonic_pi_local_last_sync, se
43884373
se
43894374
end
43904375

app/server/ruby/lib/sonicpi/runtime.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,9 @@ def __in_thread(*opts, &block)
10271027
delay = args_h[:delay]
10281028
sync_sym = args_h[:sync]
10291029
sync_bpm_sym = args_h[:sync_bpm]
1030+
1031+
#handle case where user passes both :sync and :sync_bpm opts.
1032+
# --> sync_bpm overrides sync
10301033
sync_sym = nil if sync_bpm_sym
10311034

10321035
raise ArgumentError, "in_thread's delay: opt must be a number, got #{delay.inspect}" if delay && !delay.is_a?(Numeric)

0 commit comments

Comments
 (0)