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

Method getSpace

src/jrd/MetaName.cpp:462–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

460}
461
462Dictionary::Word* Dictionary::Segment::getSpace(FB_SIZE_T len DIC_STAT_SEGMENT_PAR)
463{
464 len = getWordLength(len);
465
466 // get old position value
467 unsigned oldPos = position.load(std::memory_order_acquire);
468
469 // restart loop
470 for(;;)
471 {
472 // calculate and check new position
473 unsigned newPos = oldPos + len;
474 if (newPos >= SEG_BUFFER_SIZE)
475 break;
476
477 // try to store it safely in segment header
478 if (position.compare_exchange_weak(oldPos, newPos, std::memory_order_release, std::memory_order_acquire))
479 {
480 return reinterpret_cast<Word*>(&buffer[oldPos]);
481 }
482
483#if DIC_STATS > 0
484 ++retries;
485#endif
486 }
487
488 // Segment out of space
489 return nullptr;
490}
491
492} // namespace Jrd

Callers 5

executeMethod · 0.45
getMethod · 0.45
evlPadFunction · 0.45
allSpacesFunction · 0.45
pad_spacesFunction · 0.45

Calls 2

loadMethod · 0.45
compare_exchange_weakMethod · 0.45

Tested by

no test coverage detected