本文整理汇总了C++中Context::GetBPop方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::GetBPop方法的具体用法?C++ Context::GetBPop怎么用?C++ Context::GetBPop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::GetBPop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BlockForKeys
int Ardb::BlockForKeys(Context& ctx, const StringArray& keys, const AnyArray& vals, KeyType ktype, uint32 mstimeout)
{
if (ctx.keyslocked)
{
FATAL_LOG("Can not modify block dataset when key locked.");
}
if (mstimeout > 0)
{
ctx.GetBPop().timeout = (uint64) mstimeout * 1000 + get_current_epoch_micros();
}
ctx.GetBPop().block_keytype = ktype;
ctx.client->client->BlockRead();
LockGuard<SpinMutexLock> guard(m_block_keys_lock);
for (size_t i = 0; i < keys.size(); i++)
{
KeyPrefix prefix;
prefix.ns = ctx.ns;
prefix.key.SetString(keys[i], false);
if(vals.size() != keys.size())
{
ctx.GetBPop().keys.insert(BlockingState::BlockKeyTable::value_type(prefix, NULL));
}else
{
ctx.GetBPop().keys.insert(BlockingState::BlockKeyTable::value_type(prefix, vals[i]));
}
m_blocked_ctxs[prefix].insert(&ctx);
}
return 0;
}
示例2: UnblockKeys
int Ardb::UnblockKeys(Context& ctx, bool sync, RedisReply* reply)
{
if (ctx.keyslocked)
{
FATAL_LOG("Can not modify block dataset when key locked.");
}
if (!sync)
{
ctx.client->client->GetService().AsyncIO(ctx.client->client->GetID(), AsyncUnblockKeysCallback,
new ContexWithReply(&ctx, reply));
return 0;
}
if (NULL != reply)
{
Channel* ch = ctx.client->client;
ch->Write(*reply);
}
LockGuard<SpinMutexLock> guard(m_block_keys_lock, true);
if (ctx.bpop != NULL && !m_blocked_ctxs.empty())
{
BlockingState::BlockKeyTable::iterator it = ctx.GetBPop().keys.begin();
while (it != ctx.GetBPop().keys.end())
{
const KeyPrefix& prefix = it->first;
BlockedContextTable::iterator blocked_found = m_blocked_ctxs.find(prefix);
if (blocked_found != m_blocked_ctxs.end())
{
ContextSet& blocked_set = blocked_found->second;
blocked_set.erase(&ctx);
if (blocked_set.empty())
{
m_blocked_ctxs.erase(blocked_found);
}
}
it++;
}
ctx.ClearBPop();
}
ctx.client->client->UnblockRead();
return 0;
}