| 2815 | |
| 2816 | |
| 2817 | static void start_sweeper(thread_db* tdbb) |
| 2818 | { |
| 2819 | /************************************** |
| 2820 | * |
| 2821 | * s t a r t _ s w e e p e r |
| 2822 | * |
| 2823 | ************************************** |
| 2824 | * |
| 2825 | * Functional description |
| 2826 | * Start a thread to sweep the database. |
| 2827 | * |
| 2828 | **************************************/ |
| 2829 | SET_TDBB(tdbb); |
| 2830 | Database* const dbb = tdbb->getDatabase(); |
| 2831 | bool started = false; |
| 2832 | |
| 2833 | if (!dbb->allowSweepThread(tdbb)) |
| 2834 | return; |
| 2835 | |
| 2836 | TRA_update_counters(tdbb, dbb); |
| 2837 | |
| 2838 | try |
| 2839 | { |
| 2840 | MutexLockGuard g(swThrMutex, FB_FUNCTION); |
| 2841 | if (sweepDown) |
| 2842 | return; |
| 2843 | |
| 2844 | // perform housekeeping |
| 2845 | auto& swThr(sweepThreads()); |
| 2846 | for (unsigned n = 0; n < swThr.getCount(); ) |
| 2847 | { |
| 2848 | if (swThr[n]->tryWait()) |
| 2849 | { |
| 2850 | delete swThr[n]; |
| 2851 | swThr.remove(n); |
| 2852 | } |
| 2853 | else |
| 2854 | ++n; |
| 2855 | } |
| 2856 | |
| 2857 | AutoPtr<SweepSync> sweepSync(FB_NEW SweepSync(*getDefaultMemoryPool(), SweepParameter::runSweep)); |
| 2858 | SweepParameter* swPar = FB_NEW SweepParameter(dbb); |
| 2859 | sweepSync->run(swPar); |
| 2860 | started = true; |
| 2861 | sweepThreads().add(sweepSync.release()); |
| 2862 | } |
| 2863 | catch (const Exception&) |
| 2864 | { |
| 2865 | if (!started) |
| 2866 | dbb->clearSweepStarting(); |
| 2867 | throw; |
| 2868 | } |
| 2869 | } |
| 2870 | |
| 2871 | |
| 2872 | static void transaction_flush(thread_db* tdbb, USHORT flush_flag, TraNumber tra_number) |
no test coverage detected