本文整理汇总了C++中Page::alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ Page::alloc方法的具体用法?C++ Page::alloc怎么用?C++ Page::alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::alloc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkPageKill
void checkPageKill()
{
cerr << fmtTitle("kill", '.') << endl;
typedef BlockPage<Policy> Page;
array<void*, Page::NumBlocks> blocks;
auto& log = Page::log;
locklessCheck(createPage<Policy>()->kill(), log);
{
Page* page = createPage<Policy>();
for (size_t i = 0; i < Page::NumBlocks; ++i)
blocks[i] = page->alloc();
locklessCheck(!page->kill(), log);
for (size_t i = 0; i < Page::NumBlocks; ++i)
locklessCheckEq(
page->free(blocks[i]), i == Page::NumBlocks - 1, log);
}
{
Page* page = createPage<Policy>();
for (size_t i = 0; i < Page::NumBlocks; ++i)
blocks[i] = page->alloc();
for (size_t i = 0; i < Page::NumBlocks / 2; ++i)
locklessCheckEq(
page->free(blocks[i]), i == Page::NumBlocks - 1, log);
locklessCheck(!page->kill(), log);
for (size_t i = Page::NumBlocks / 2; i < Page::NumBlocks; ++i)
locklessCheckEq(
page->free(blocks[i]), i == Page::NumBlocks - 1, log);
}
{
Page* page = createPage<Policy>();
for (size_t i = 0; i < Page::NumBlocks; ++i)
blocks[i] = page->alloc();
for (size_t i = 0; i < Page::NumBlocks; ++i)
locklessCheck(!page->free(blocks[i]), log);
locklessCheck(page->kill(), log);
}
}
示例2: checkPageAlloc
void checkPageAlloc()
{
cerr << fmtTitle("alloc", '.') << endl;
typedef BlockPage<Policy> Page;
Page* page = createPage<Policy>();
auto& log = Page::log;
array<void*, Page::NumBlocks> blocks;
for (size_t i = 0; i < Page::NumBlocks; ++i) {
locklessCheck(page->hasFreeBlock(), log);
void* block = page->alloc();
fillBlock<Policy>(block, i);
page->free(blocks[i] = block);
if (!i) {
locklessCheckEq(
uintptr_t(page) + (Page::MetadataBlocks * Policy::BlockSize),
uintptr_t(blocks[0]),
log);
}
else {
locklessCheckGt(blocks[i], page, log);
locklessCheckLe(
uintptr_t(blocks[i]) + Policy::BlockSize,
uintptr_t(page) + Policy::PageSize,
log);
locklessCheckEq(
uintptr_t(blocks[i-1]) + Policy::BlockSize,
uintptr_t(blocks[i]),
log);
}
locklessCheckEq(page, Page::pageForBlock(blocks[i]), log);
}
for (size_t iteration = 0; iteration < 2; ++iteration) {
for (size_t i = 0; i < Page::NumBlocks; ++i)
locklessCheckEq(blocks[i], page->alloc(), log);
for (size_t i = 0; i < Page::NumBlocks; ++i)
page->free(blocks[i]);
}
locklessCheck(page->kill(), log);
}
示例3: multipleAllocFreeTest
void multipleAllocFreeTest() {
int i;
Page *page;
uint32_t ps = ((LocalEnvironment *)m_env)->config().page_size_bytes;
for (i = 0; i < 10; i++) {
page = new Page(((LocalEnvironment *)m_env)->device());
page->alloc(0, ps);
/* i+2 since we need 1 page for the header page and one page
* for the root page */
if (!m_inmemory)
REQUIRE(page->get_address() == (i + 2) * ps);
delete page;
}
}
示例4: checkPageFull
void checkPageFull()
{
cerr << fmtTitle("full", '.') << endl;
typedef BlockPage<Policy> Page;
Page* page = createPage<Policy>();
array<void*, Page::NumBlocks> blocks;
for (size_t i = 0; i < Page::NumBlocks; ++i)
page->free(blocks[i] = page->alloc());
for (size_t k = 1; k < Page::NumBlocks; ++k) {
for (size_t i = 0; i < Page::NumBlocks; ++i)
page->alloc();
locklessCheck(!page->hasFreeBlock(), NullLog);
for (size_t i = 0; i < Page::NumBlocks; i += k)
page->free(blocks[i]);
locklessCheck(page->hasFreeBlock(), NullLog);
for (size_t i = 0; i < Page::NumBlocks; i += k)
page->alloc();
locklessCheck(!page->hasFreeBlock(), NullLog);
for (size_t i = 0; i < Page::NumBlocks; ++i)
page->free(blocks[i]);
locklessCheck(page->hasFreeBlock(), NullLog);
}
locklessCheck(page->kill(), NullLog);
}
示例5: allocFreeTest
void allocFreeTest() {
Page *page;
page = new Page(((LocalEnvironment *)m_env)->device());
page->alloc(0, 1024);
delete page;
}