| 3016 | |
| 3017 | |
| 3018 | void BufferControl::cache_writer(BufferControl* bcb) |
| 3019 | { |
| 3020 | /************************************** |
| 3021 | * |
| 3022 | * c a c h e _ w r i t e r |
| 3023 | * |
| 3024 | ************************************** |
| 3025 | * |
| 3026 | * Functional description |
| 3027 | * Write dirty pages to database to maintain an adequate supply of free pages. |
| 3028 | * |
| 3029 | **************************************/ |
| 3030 | FbLocalStatus status_vector; |
| 3031 | Database* const dbb = bcb->bcb_database; |
| 3032 | |
| 3033 | try |
| 3034 | { |
| 3035 | UserId user; |
| 3036 | user.setUserName("Cache Writer"); |
| 3037 | |
| 3038 | Jrd::Attachment* const attachment = Jrd::Attachment::create(dbb, nullptr); |
| 3039 | RefPtr<SysStableAttachment> sAtt(FB_NEW SysStableAttachment(attachment)); |
| 3040 | attachment->setStable(sAtt); |
| 3041 | attachment->att_filename = dbb->dbb_filename; |
| 3042 | attachment->att_user = &user; |
| 3043 | |
| 3044 | BackgroundContextHolder tdbb(dbb, attachment, &status_vector, FB_FUNCTION); |
| 3045 | Jrd::Attachment::UseCountHolder use(attachment); |
| 3046 | |
| 3047 | try |
| 3048 | { |
| 3049 | LCK_init(tdbb, LCK_OWNER_attachment); |
| 3050 | PAG_header(tdbb, true); |
| 3051 | PAG_attachment_id(tdbb); |
| 3052 | TRA_init(attachment); |
| 3053 | |
| 3054 | Monitoring::publishAttachment(tdbb); |
| 3055 | |
| 3056 | sAtt->initDone(); |
| 3057 | |
| 3058 | bcb->bcb_flags |= BCB_cache_writer; |
| 3059 | bcb->bcb_flags &= ~BCB_writer_start; |
| 3060 | |
| 3061 | // Notify our creator that we have started |
| 3062 | bcb->bcb_writer_init.release(); |
| 3063 | |
| 3064 | while (bcb->bcb_flags & BCB_cache_writer) |
| 3065 | { |
| 3066 | bcb->bcb_flags |= BCB_writer_active; |
| 3067 | #ifdef CACHE_READER |
| 3068 | SLONG starting_page = -1; |
| 3069 | #endif |
| 3070 | |
| 3071 | if (dbb->dbb_flags & DBB_suspend_bgio) |
| 3072 | { |
| 3073 | EngineCheckout cout(tdbb, FB_FUNCTION); |
| 3074 | bcb->bcb_writer_sem.tryEnter(10); |
| 3075 | continue; |
nothing calls this directly
no test coverage detected