equal
deleted
inserted
replaced
47 |
47 |
48 #include <unistd.h> |
48 #include <unistd.h> |
49 #include <errno.h> |
49 #include <errno.h> |
50 |
50 |
51 QT_BEGIN_NAMESPACE |
51 QT_BEGIN_NAMESPACE |
|
52 |
|
53 #ifdef SYMBIAN_GRAPHICS_WSERV_QT_EFFECTS |
|
54 // when the system UI is Qt based, priority drop is not needed as CPU starved processes will not be killed. |
|
55 #undef QT_SYMBIAN_PRIORITY_DROP |
|
56 #else |
|
57 #define QT_SYMBIAN_PRIORITY_DROP |
|
58 #endif |
52 |
59 |
53 #define WAKE_UP_PRIORITY CActive::EPriorityStandard |
60 #define WAKE_UP_PRIORITY CActive::EPriorityStandard |
54 #define TIMER_PRIORITY CActive::EPriorityHigh |
61 #define TIMER_PRIORITY CActive::EPriorityHigh |
55 #define NULLTIMER_PRIORITY CActive::EPriorityLow |
62 #define NULLTIMER_PRIORITY CActive::EPriorityLow |
56 #define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle |
63 #define COMPLETE_DEFERRED_ACTIVE_OBJECTS_PRIORITY CActive::EPriorityIdle |
695 } |
702 } |
696 |
703 |
697 bool handledSymbianEvent = false; |
704 bool handledSymbianEvent = false; |
698 m_interrupt = false; |
705 m_interrupt = false; |
699 |
706 |
|
707 #ifdef QT_SYMBIAN_PRIORITY_DROP |
700 /* |
708 /* |
701 * This QTime variable is used to measure the time it takes to finish |
709 * This QTime variable is used to measure the time it takes to finish |
702 * the event loop. If we take too long in the loop, other processes |
710 * the event loop. If we take too long in the loop, other processes |
703 * may be starved and killed. After the first event has completed, we |
711 * may be starved and killed. After the first event has completed, we |
704 * take the current time, and if the remaining events take longer than |
712 * take the current time, and if the remaining events take longer than |
712 SubsequentRun, |
720 SubsequentRun, |
713 TimeStarted |
721 TimeStarted |
714 } timeState = FirstRun; |
722 } timeState = FirstRun; |
715 |
723 |
716 TProcessPriority priority; |
724 TProcessPriority priority; |
|
725 #endif |
717 |
726 |
718 while (1) { |
727 while (1) { |
719 if (block) { |
728 if (block) { |
720 // This is where Qt will spend most of its time. |
729 // This is where Qt will spend most of its time. |
721 CActiveScheduler::Current()->WaitForAnyRequest(); |
730 CActiveScheduler::Current()->WaitForAnyRequest(); |
725 } |
734 } |
726 // This one should return without delay. |
735 // This one should return without delay. |
727 CActiveScheduler::Current()->WaitForAnyRequest(); |
736 CActiveScheduler::Current()->WaitForAnyRequest(); |
728 } |
737 } |
729 |
738 |
|
739 #ifdef QT_SYMBIAN_PRIORITY_DROP |
730 if (timeState == SubsequentRun) { |
740 if (timeState == SubsequentRun) { |
731 time.start(); |
741 time.start(); |
732 timeState = TimeStarted; |
742 timeState = TimeStarted; |
733 } |
743 } |
|
744 #endif |
734 |
745 |
735 TInt error; |
746 TInt error; |
736 handledSymbianEvent = CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle); |
747 handledSymbianEvent = CActiveScheduler::RunIfReady(error, KMinTInt); |
737 if (error) { |
748 if (error) { |
738 qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error); |
749 qWarning("CActiveScheduler::RunIfReady() returned error: %i\n", error); |
739 CActiveScheduler::Current()->Error(error); |
750 CActiveScheduler::Current()->Error(error); |
740 } |
751 } |
741 |
752 |
745 handledAnyEvent = true; |
756 handledAnyEvent = true; |
746 if (m_interrupt) { |
757 if (m_interrupt) { |
747 break; |
758 break; |
748 } |
759 } |
749 block = false; |
760 block = false; |
|
761 #ifdef QT_SYMBIAN_PRIORITY_DROP |
750 if (timeState == TimeStarted && time.elapsed() > 100) { |
762 if (timeState == TimeStarted && time.elapsed() > 100) { |
751 priority = m_processHandle.Priority(); |
763 priority = m_processHandle.Priority(); |
752 m_processHandle.SetPriority(EPriorityBackground); |
764 m_processHandle.SetPriority(EPriorityBackground); |
753 time.start(); |
765 time.start(); |
754 // Slight chance of race condition in the next lines, but nothing fatal |
766 // Slight chance of race condition in the next lines, but nothing fatal |
757 m_processHandle.SetPriority(priority); |
769 m_processHandle.SetPriority(priority); |
758 } |
770 } |
759 } |
771 } |
760 if (timeState == FirstRun) |
772 if (timeState == FirstRun) |
761 timeState = SubsequentRun; |
773 timeState = SubsequentRun; |
|
774 #endif |
762 }; |
775 }; |
763 |
776 |
764 emit awake(); |
777 emit awake(); |
765 } QT_CATCH (const std::exception& ex) { |
778 } QT_CATCH (const std::exception& ex) { |
766 #ifndef QT_NO_EXCEPTIONS |
779 #ifndef QT_NO_EXCEPTIONS |