summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/schedule.h
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2011-04-27 20:34:45 +0000
committer Aaron Giles <aaron@aarongiles.com>2011-04-27 20:34:45 +0000
commitaf94c692bb616def82ec38e717dea5e507d310fe (patch)
tree62402705206111cd10ec15d585de338f2881ea14 /src/emu/schedule.h
parent9092f1596454dd7b76e954038f7dd25f3305e345 (diff)
Switch to using delegates for some callbacks:
- non-device timer callbacks - machine state changing callbacks - configuration callbacks - per-screen VBLANK callbacks - DRC backend callbacks For the timer case only, I added wrappers for the old-style functions. Over time, drivers should switch to device timers instead, reducing the number of timers that are directly allocated through the scheduler.
Diffstat (limited to 'src/emu/schedule.h')
-rw-r--r--src/emu/schedule.h26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/emu/schedule.h b/src/emu/schedule.h
index 56af090538e..eac0b494829 100644
--- a/src/emu/schedule.h
+++ b/src/emu/schedule.h
@@ -71,6 +71,9 @@
//**************************************************************************
// timer callbacks look like this
+typedef delegate<void (void *, INT32)> timer_expired_delegate;
+
+// old-skool callbacks are like this
typedef void (*timer_expired_func)(running_machine &machine, void *ptr, INT32 param);
// stub for when the ptr parameter points to a class
@@ -96,7 +99,7 @@ class emu_timer
~emu_timer();
// allocation and re-use
- emu_timer &init(running_machine &machine, timer_expired_func callback, const char *name, void *ptr, bool temporary);
+ emu_timer &init(running_machine &machine, timer_expired_delegate callback, void *ptr, bool temporary);
emu_timer &init(device_t &device, device_timer_id id, void *ptr, bool temporary);
emu_timer &release();
@@ -132,10 +135,9 @@ private:
running_machine * m_machine; // reference to the owning machine
emu_timer * m_next; // next timer in order in the list
emu_timer * m_prev; // previous timer in order in the list
- timer_expired_func m_callback; // callback function
+ timer_expired_delegate m_callback; // callback function
INT32 m_param; // integer parameter
void * m_ptr; // pointer parameter
- const char * m_func; // string name of the callback function
bool m_enabled; // is the timer enabled?
bool m_temporary; // is the timer temporary?
attotime m_period; // the repeat frequency of the timer
@@ -148,7 +150,7 @@ private:
// ======================> device_scheduler
-class device_scheduler
+class device_scheduler : public bindable_object
{
friend class device_execute_interface;
friend class emu_timer;
@@ -172,10 +174,16 @@ public:
void boost_interleave(attotime timeslice_time, attotime boost_duration);
// timers, specified by callback/name
- emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL);
- void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL);
- void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL);
- void synchronize(timer_expired_func callback = NULL, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); }
+ emu_timer *timer_alloc(timer_expired_delegate callback, void *ptr = NULL);
+ void timer_set(attotime duration, timer_expired_delegate callback, int param = 0, void *ptr = NULL);
+ void timer_pulse(attotime period, timer_expired_delegate callback, int param = 0, void *ptr = NULL);
+ void synchronize(timer_expired_delegate callback = timer_expired_delegate(), int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, param, ptr); }
+
+ // timers with old-skool callbacks
+ emu_timer *timer_alloc(timer_expired_func callback, const char *name, void *ptr = NULL) { return timer_alloc(timer_expired_delegate(callback, name, &machine()), ptr); }
+ void timer_set(attotime duration, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_set(duration, timer_expired_delegate(callback, name, &machine()), param, ptr); }
+ void timer_pulse(attotime period, timer_expired_func callback, const char *name, int param = 0, void *ptr = NULL) { timer_pulse(period, timer_expired_delegate(callback, name, &machine()), param, ptr); }
+ void synchronize(timer_expired_func callback, const char *name = NULL, int param = 0, void *ptr = NULL) { timer_set(attotime::zero, callback, name, param, ptr); }
// timers, specified by device/id; generally devices should use the device_t methods instead
emu_timer *timer_alloc(device_t &device, device_timer_id id = 0, void *ptr = NULL);
@@ -186,7 +194,7 @@ public:
private:
// callbacks
- void timed_trigger(running_machine &machine, INT32 param);
+ void timed_trigger(void *ptr, INT32 param);
void postload();
// scheduling helpers