summaryrefslogtreecommitdiff
path: root/vcl/qa
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-01-25 15:53:15 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2017-07-13 12:10:23 +0200
commit917be98e3f277960635ac66bcea510c2454c80d6 (patch)
tree18def396ae400eb1151211c863d44be457a7831a /vcl/qa
parent23beae53b43484d82949019a3279362c7e1dfb4b (diff)
Round-robin invoked tasks
Add some round-robin to the task processing, so equal priority (auto) tasks won't always be scheduled, if there are multiple tasks with the same priority. Change-Id: Ice111aa5f85e9181b3ee9799ca4df0d58f210fe9
Diffstat (limited to 'vcl/qa')
-rw-r--r--vcl/qa/cppunit/timer.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/timer.cxx b/vcl/qa/cppunit/timer.cxx
index 83b0a7cc01e5..dcd11319e293 100644
--- a/vcl/qa/cppunit/timer.cxx
+++ b/vcl/qa/cppunit/timer.cxx
@@ -70,6 +70,7 @@ public:
void testTriggerIdleFromIdle();
void testInvokedReStart();
void testPriority();
+ void testRoundRobin();
CPPUNIT_TEST_SUITE(TimerTest);
CPPUNIT_TEST(testIdle);
@@ -88,6 +89,7 @@ public:
CPPUNIT_TEST(testTriggerIdleFromIdle);
CPPUNIT_TEST(testInvokedReStart);
CPPUNIT_TEST(testPriority);
+ CPPUNIT_TEST(testRoundRobin);
CPPUNIT_TEST_SUITE_END();
};
@@ -487,6 +489,46 @@ void TimerTest::testPriority()
}
}
+
+class TestAutoIdleRR : public AutoIdle
+{
+ sal_uInt32 &mrCount;
+
+ DECL_LINK( IdleRRHdl, Timer *, void );
+
+public:
+ TestAutoIdleRR( sal_uInt32 &rCount,
+ const sal_Char *pDebugName )
+ : AutoIdle( pDebugName )
+ , mrCount( rCount )
+ {
+ CPPUNIT_ASSERT_EQUAL( mrCount, sal_uInt32(0) );
+ SetInvokeHandler( LINK( this, TestAutoIdleRR, IdleRRHdl ) );
+ Start();
+ }
+};
+
+IMPL_LINK_NOARG(TestAutoIdleRR, IdleRRHdl, Timer *, void)
+{
+ ++mrCount;
+ if ( mrCount == 3 )
+ Stop();
+}
+
+void TimerTest::testRoundRobin()
+{
+ sal_uInt32 nCount1 = 0, nCount2 = 0;
+ TestAutoIdleRR aIdle1( nCount1, "TestAutoIdleRR aIdle1" ),
+ aIdle2( nCount2, "TestAutoIdleRR aIdle2" );
+ while ( Application::Reschedule() )
+ {
+ CPPUNIT_ASSERT( nCount1 == nCount2 || nCount1 - 1 == nCount2 );
+ CPPUNIT_ASSERT( nCount1 <= 3 );
+ CPPUNIT_ASSERT( nCount2 <= 3 );
+ }
+ CPPUNIT_ASSERT( 3 == nCount1 && 3 == nCount2 );
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(TimerTest);
CPPUNIT_PLUGIN_IMPLEMENT();