summaryrefslogtreecommitdiff
path: root/include/vcl/idle.hxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2016-09-14 13:48:02 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2017-01-17 16:22:57 +0100
commit59b84bc78dff2adb265d9fa8edb4c42794cf9771 (patch)
tree929a0dd7e3d16dfc9d49dac3470fd11546819504 /include/vcl/idle.hxx
parent1531152eff8061d63be5d98641fcafaa1da05167 (diff)
Change Idle to be a Timer subclass
Drops a lot of duplicated code, as Idle is just a convenience class for instant, mostly low priority timers. Change-Id: I847592e92e86d15ab1cab168bf0e667322e48048
Diffstat (limited to 'include/vcl/idle.hxx')
-rw-r--r--include/vcl/idle.hxx36
1 files changed, 24 insertions, 12 deletions
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index 9f491e1ad9f7..85ea758096a9 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -20,12 +20,19 @@
#ifndef INCLUDED_VCL_IDLE_HXX
#define INCLUDED_VCL_IDLE_HXX
-#include <tools/link.hxx>
-#include <vcl/scheduler.hxx>
+#include <vcl/timer.hxx>
-class VCL_DLLPUBLIC Idle : public Task
+/**
+ * An idle is a timer to be scheduled immediately.
+ *
+ * It's - more or less - just a convenience class.
+ */
+class VCL_DLLPUBLIC Idle : public Timer
{
- Link<Idle *, void> maIdleHdl; // Callback Link
+private:
+ // Delete all timeout specific functions, we don't want in an Idle
+ void SetTimeout( sal_uInt64 nTimeoutMs ) = delete;
+ sal_uInt64 GetTimeout() const = delete;
protected:
virtual bool ReadyForSchedule( bool bIdle, sal_uInt64 nTimeNow ) const override;
@@ -34,18 +41,23 @@ protected:
public:
Idle( const sal_Char *pDebugName = nullptr );
- Idle( const Idle& rIdle );
- virtual void Start() override;
+ virtual void Start() override;
- /// Make it possible to associate a callback with this idle handler
- /// of course, you can also sub-class and override 'Invoke'
- void SetIdleHdl( const Link<Idle *, void>& rLink ) { maIdleHdl = rLink; }
- const Link<Idle *, void>& GetIdleHdl() const { return maIdleHdl; }
- virtual void Invoke() override;
- Idle& operator=( const Idle& rIdle );
+ /**
+ * Convenience function for more readable code
+ *
+ * TODO: actually rename it and it's instances to SetInvokeHandler
+ */
+ inline void SetIdleHdl( const Link<Idle *, void>& rLink );
};
+inline void Idle::SetIdleHdl( const Link<Idle*, void> &rLink )
+{
+ SetInvokeHandler( Link<Timer*, void>( rLink.GetInstance(),
+ reinterpret_cast< Link<Timer*, void>::Stub* >( rLink.GetFunction()) ) );
+}
+
#endif // INCLUDED_VCL_IDLE_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */