Skip to content

Commit 45c2d80

Browse files
committed
Spider - re-introduce last sync cache
This was inadvertantly removed whilst weaving in Link logic, but is actually necessary to ensure that syncing is correctly ordered.
1 parent 8bf42e8 commit 45c2d80

File tree

1 file changed

+15
-1
lines changed
  • app/server/ruby/lib/sonicpi/lang

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4189,6 +4189,7 @@ 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)
41924193

41934194
# Schedule messages
41944195
__schedule_delayed_blocks_and_messages!
@@ -4342,15 +4343,28 @@ def sync_event(*args)
43424343

43434344
__schedule_delayed_blocks_and_messages!
43444345

4345-
t = current_time
4346+
last_sync = __system_thread_locals.get(:sonic_pi_local_last_sync, nil)
4347+
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+
t = current_time
43464357
p = __system_thread_locals.get(:sonic_pi_spider_thread_priority, -100)
43474358
i = __current_thread_id
43484359
d = __system_thread_locals.get(:sonic_pi_spider_thread_delta, 0)
43494360
b = current_beat
43504361
m = current_bpm_mode
4362+
end
43514363

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

4366+
__system_thread_locals.set_local :sonic_pi_local_last_sync, se
4367+
43544368
__system_thread_locals.set(:sonic_pi_spider_synced, true)
43554369

43564370
if bpm_sync

0 commit comments

Comments
 (0)