summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-06-04 18:40:14 +1000
committer Vas Crabb <vas@vastheman.com>2022-06-04 18:40:14 +1000
commit0f40df67a8a18972babe5ae418e861bca4d19f1c (patch)
tree546c7b216335509bb7194d131a55dd89143da575 /src/emu
parentc93195e72f81105ec99ae14692b63e8318a02948 (diff)
emu/schedule.cpp: Reduced spam from use of synchronize() - it serves a purpose for now.
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/schedule.cpp19
-rw-r--r--src/emu/schedule.h5
2 files changed, 14 insertions, 10 deletions
diff --git a/src/emu/schedule.cpp b/src/emu/schedule.cpp
index ef3961c84f4..cc69a542914 100644
--- a/src/emu/schedule.cpp
+++ b/src/emu/schedule.cpp
@@ -72,13 +72,13 @@ emu_timer::~emu_timer()
// re-allocated as a non-device timer
//-------------------------------------------------
-inline emu_timer &emu_timer::init(running_machine &machine, timer_expired_delegate callback, bool temporary)
+emu_timer &emu_timer::init(running_machine &machine, timer_expired_delegate &&callback, bool temporary)
{
// ensure the entire timer state is clean
m_machine = &machine;
m_next = nullptr;
m_prev = nullptr;
- m_callback = callback;
+ m_callback = std::move(callback);
m_param = 0;
m_enabled = false;
m_temporary = temporary;
@@ -501,14 +501,17 @@ void device_scheduler::trigger(int trigid, const attotime &after)
if (m_execute_list == nullptr)
rebuild_execute_list();
- // if we have a non-zero time, schedule a timer
if (after != attotime::zero)
+ {
+ // if we have a non-zero time, schedule a timer
timer_set(after, timer_expired_delegate(FUNC(device_scheduler::timed_trigger), this), trigid);
-
- // send the trigger to everyone who cares
+ }
else
- for (device_execute_interface *exec = m_execute_list; exec != nullptr; exec = exec->m_nextexec)
+ {
+ // send the trigger to everyone who cares
+ for (device_execute_interface *exec = m_execute_list; exec; exec = exec->m_nextexec)
exec->trigger(trigid);
+ }
}
@@ -533,7 +536,7 @@ void device_scheduler::boost_interleave(const attotime &timeslice_time, const at
emu_timer *device_scheduler::timer_alloc(timer_expired_delegate callback)
{
- return &m_timer_allocator.alloc()->init(machine(), callback, false);
+ return &m_timer_allocator.alloc()->init(machine(), std::move(callback), false);
}
@@ -545,7 +548,7 @@ emu_timer *device_scheduler::timer_alloc(timer_expired_delegate callback)
void device_scheduler::timer_set(const attotime &duration, timer_expired_delegate callback, int param)
{
- m_timer_allocator.alloc()->init(machine(), callback, true).adjust(duration, param);
+ m_timer_allocator.alloc()->init(machine(), std::move(callback), true).adjust(duration, param);
}
diff --git a/src/emu/schedule.h b/src/emu/schedule.h
index e009850cf34..dbaca005572 100644
--- a/src/emu/schedule.h
+++ b/src/emu/schedule.h
@@ -45,7 +45,7 @@ class emu_timer
~emu_timer();
// allocation and re-use
- emu_timer &init(running_machine &machine, timer_expired_delegate callback, bool temporary);
+ emu_timer &init(running_machine &machine, timer_expired_delegate &&callback, bool temporary) ATTR_HOT;
emu_timer &release();
public:
@@ -120,7 +120,8 @@ public:
emu_timer *timer_alloc(timer_expired_delegate callback);
[[deprecated("timer_set is deprecated; please avoid anonymous timers. Use TIMER_CALLBACK_MEMBER and an allocated emu_timer instead.")]]
void timer_set(const attotime &duration, timer_expired_delegate callback, int param = 0);
- void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0) { timer_set(attotime::zero, callback, param); }
+ void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0)
+ { m_timer_allocator.alloc()->init(machine(), std::move(callback), true).adjust(attotime::zero, param); }
// debugging
void dump_timers() const;