MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / cache_reader

Method cache_reader

src/jrd/cch.cpp:2865–3014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2863
2864#ifdef CACHE_READER
2865void BufferControl::cache_reader(BufferControl* bcb)
2866{
2867/**************************************
2868 *
2869 * c a c h e _ r e a d e r
2870 *
2871 **************************************
2872 *
2873 * Functional description
2874 * Prefetch pages into cache for sequential scans.
2875 * Use asynchronous I/O to keep two prefetch requests
2876 * busy at a time.
2877 *
2878 **************************************/
2879 Database* dbb = bcb->bcb_database;
2880 Database::SyncGuard dsGuard(dbb);
2881
2882 FbLocalStatus status_vector;
2883
2884 // Establish a thread context.
2885 ThreadContextHolder tdbb(status_vector);
2886
2887 // Dummy attachment needed for lock owner identification.
2888 tdbb->setDatabase(dbb);
2889 Jrd::Attachment* const attachment = Attachment::create(dbb, nullptr);
2890 tdbb->setAttachment(attachment);
2891 attachment->att_filename = dbb->dbb_filename;
2892 Jrd::ContextPoolHolder context(tdbb, bcb->bcb_bufferpool);
2893
2894 // This try block is specifically to protect the LCK_init call: if
2895 // LCK_init fails we won't be able to accomplish anything anyway, so
2896 // return, unlike the other try blocks further down the page.
2897
2898 BufferControl* bcb = NULL;
2899
2900 try {
2901
2902 LCK_init(tdbb, LCK_OWNER_attachment);
2903 TRA_init(attachment);
2904 bcb = dbb->dbb_bcb;
2905 bcb->bcb_flags |= BCB_cache_reader;
2906 dbb->dbb_reader_init.post(); // Notify our creator that we have started
2907 }
2908 catch (const Firebird::Exception& ex)
2909 {
2910 ex.stuffException(status_vector);
2911 iscDbLogStatus(dbb->dbb_filename.c_str(), status_vector);
2912 return 0;
2913 }
2914
2915 try {
2916
2917 // Set up dual prefetch control blocks to keep multiple prefetch
2918 // requests active at a time. Also helps to prevent the cache reader
2919 // from becoming dedicated or locked into a single request's prefetch demands.
2920
2921 prf prefetch1, prefetch2;
2922 prefetch_init(&prefetch1, tdbb);

Callers

nothing calls this directly

Calls 15

createFunction · 0.85
LCK_initFunction · 0.85
TRA_initFunction · 0.85
iscDbLogStatusFunction · 0.85
prefetch_initFunction · 0.85
prefetch_prologueFunction · 0.85
prefetch_ioFunction · 0.85
prefetch_epilogueFunction · 0.85
JRD_rescheduleFunction · 0.85
get_dirty_bufferFunction · 0.85
write_bufferFunction · 0.85
LCK_finiFunction · 0.85

Tested by

no test coverage detected