本文整理汇总了C++中weak_ptr::lock方法的典型用法代码示例。如果您正苦于以下问题:C++ weak_ptr::lock方法的具体用法?C++ weak_ptr::lock怎么用?C++ weak_ptr::lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weak_ptr
的用法示例。
在下文中一共展示了weak_ptr::lock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moveto
weak_ptr<TTrieNode> TStaticTemplateMatcher::moveto(weak_ptr<TTrieNode> node, char symbol) {
if (node.lock() == sink)
return weak_ptr<TTrieNode>(getroot());
if (node.lock()->isEdge(symbol))
return weak_ptr<TTrieNode>(node.lock()->next(symbol));
return moveto(suf_link_move(node),symbol);
}
示例2: SwapCells
void FieldController::SwapCells(weak_ptr<CrystalController> wcell1, weak_ptr<CrystalController> wcell2)
{
m_glow.lock()->SetEnabled(false);
m_swapped1 = wcell1;
m_swapped2 = wcell2;
auto cell1 = wcell1.lock();
auto cell2 = wcell2.lock();
int x = cell1->m_cellX;
int y = cell1->m_cellY;
printf("swapping cells[x,y]: [%d,%d] and [%d,%d] \n", cell1->m_cellX, cell1->m_cellY, cell2->m_cellX, cell2->m_cellY);
cell1->m_cellX = cell2->m_cellX;
cell1->m_cellY = cell2->m_cellY;
cell2->m_cellX = x;
cell2->m_cellY = y;
m_cells[cell1->m_cellY][cell1->m_cellX] = wcell1;
m_cells[cell2->m_cellY][cell2->m_cellX] = wcell2;
}
示例3: in
static QGpgMEVerifyOpaqueJob::result_type verify_opaque( Context * ctx, QThread * thread, const weak_ptr<QIODevice> & signedData_, const weak_ptr<QIODevice> & plainText_ ) {
const shared_ptr<QIODevice> plainText = plainText_.lock();
const shared_ptr<QIODevice> signedData = signedData_.lock();
const _detail::ToThreadMover ptMover( plainText, thread );
const _detail::ToThreadMover sdMover( signedData, thread );
QGpgME::QIODeviceDataProvider in( signedData );
const Data indata( &in );
if ( !plainText ) {
QGpgME::QByteArrayDataProvider out;
Data outdata( &out );
const VerificationResult res = ctx->verifyOpaqueSignature( indata, outdata );
Error ae;
const QString log = _detail::audit_log_as_html( ctx, ae );
return make_tuple( res, out.data(), log, ae );
} else {
QGpgME::QIODeviceDataProvider out( plainText );
Data outdata( &out );
const VerificationResult res = ctx->verifyOpaqueSignature( indata, outdata );
Error ae;
const QString log = _detail::audit_log_as_html( ctx, ae );
return make_tuple( res, QByteArray(), log, ae );
}
}
示例4: if
static bool __cdecl alphabeticalG3DLast(weak_ptr<Texture> const& elem1, weak_ptr<Texture> const& elem2) {
const shared_ptr<Texture>& elem1Locked = elem1.lock();
const shared_ptr<Texture>& elem2Locked = elem2.lock();
if (isNull(elem1Locked)) {
return true;
} else if (isNull(elem2Locked)) {
return false;
} else {
return alphabeticalIgnoringCaseG3DLastLessThan(elem1Locked->name(), elem2Locked->name());
}
}
示例5: alphabeticalTextureLT
static bool __cdecl alphabeticalTextureLT(weak_ptr<Texture> const& elem1, weak_ptr<Texture> const& elem2) {
const shared_ptr<Texture>& elem1Locked = elem1.lock();
const shared_ptr<Texture>& elem2Locked = elem2.lock();
if (isNull(elem1Locked)) {
return true;
} else if (isNull(elem2Locked)) {
return false;
} else {
return elem1Locked->name() < elem2Locked->name();
}
}
示例6: isParentPose
/**
* Returns true if P is part of the parent chain from this pose.
*/
bool isParentPose(const shared_ptr< const self >& P) const {
if(Parent.expired()) {
if(P)
return true;
else
return false;
} else {
if(P)
return false;
else if(P == Parent.lock())
return true;
else
return Parent.lock()->isParentPose(P);
};
};
示例7: getPoseRelativeTo
/**
* Returns this 2D pose relative to pose P.
*/
self getPoseRelativeTo(const shared_ptr< const self >& P) const {
if(!P)
return getGlobalPose();
if(isParentPose(P)) {
if(Parent.lock() == P)
return *this;
else
return Parent.lock()->getPoseRelativeTo(P) * (*this);
} else if(P->isParentPose( rtti::rk_static_ptr_cast< const self >(mThis)))
return ~(P->getPoseRelativeTo( rtti::rk_static_ptr_cast< const self >(mThis)));
else if(Parent.expired())
return (~(P->getGlobalPose())) * (*this);
else
return Parent.lock()->getPoseRelativeTo(P) * (*this);
};
示例8: DelTermSession
uint32_t BusinessPool::DelTermSession(weak_ptr<TermSession> ts)
{
shared_ptr<TermSession> sp_ts(ts.lock());
if (!sp_ts) {
logger_.Warn("[删除终端会话]******对应的终端会话不存在******");
return 0;
}
CASession *cs = sp_ts->ca_session_;
if (cs == NULL) {
logger_.Warn("[删除终端会话]******对应的CA会话不存在******");
return 0;
}
cs->Remove(sp_ts->Id());
logger_.Warn("[删除终端会话][CAId:" SFMT64U "][TSId:0x" SFMT64X "]", cs->Id(), sp_ts->Id());
CASessionMgr *cs_mgr = pool_relation_ca_session_mgr_[getIdByTermSessionId(sp_ts->Id())];
cs_mgr->DetachTermSessionInfo(sp_ts->Id());
uint32_t ret = cs->termCnt();
//if no terminal session in ca session,
// remove ca session.
if (cs->termCnt() == 0) {
logger_.Warn("[删除终端会话][CAId:" SFMT64U "][TSId:0x" SFMT64X "],CA会话中无终端,删除CA会话", cs->Id(), sp_ts->Id());
CASessionMgr *cs_mgr = pool_relation_ca_session_mgr_[getIdByTermSessionId(sp_ts->Id())];
cs_mgr->Detach(cs->Id());
cs_mgr->Destory(cs);
}
return ret;
}
示例9: RemoveFromParent
void RemoveFromParent()
{
if( auto p = Parent.lock() )
{
p->RemoveChild( shared_from_this() );
}
}
示例10: MyFather
void MyFather() {
auto father = father_.lock();
if (father)
cout << father->name_ << " is MyFather\n";
else
cout << "father is gone\n";
}
示例11: updatePhysics
void VRPhysicsManager::updatePhysics( weak_ptr<VRThread> wthread) {
if (dynamicsWorld == 0) return;
long long dt,t0,t1,t2,t3;
auto thread = wthread.lock();
if (thread == 0) return;
t0 = thread->t_last;
t1 = getTime();
thread->t_last = t1;
dt = t1-t0;
{
MLock lock(mtx);
prepareObjects();
for (auto f : updateFktsPre) (*f)(0);
dynamicsWorld->stepSimulation(1e-6*dt, 30);
for (auto f : updateFktsPost) (*f)(0);
}
t2 = getTime();
dt = t2-t1;
//sleep up to 500 fps
if (dt < PHYSICS_THREAD_TIMESTEP_MS * 1000) this_thread::sleep_for(chrono::microseconds(PHYSICS_THREAD_TIMESTEP_MS * 1000 -dt));
t3 = getTime();
MLock lock(mtx);
fps = 1e6/(t3-t1);
}
示例12: GetGlobalDisplay
static CDisplayPtr GetGlobalDisplay()
{
static weak_ptr<CDisplay> display_global;
CDisplayPtr display(display_global.lock());
if(display)
{
if(display->lost())
{
CLog::Log(LOGERROR, "VAAPI - vaapi display is in lost state");
display.reset();
}
return display;
}
VADisplay disp;
disp = vaGetDisplayGLX(g_Windowing.GetDisplay());
int major_version, minor_version;
VAStatus res = vaInitialize(disp, &major_version, &minor_version);
if(res != VA_STATUS_SUCCESS)
{
CLog::Log(LOGERROR, "VAAPI - unable to initialize display %d - %s", res, vaErrorStr(res));
return display;
}
CLog::Log(LOGDEBUG, "VAAPI - initialize version %d.%d", major_version, minor_version);
display = CDisplayPtr(new CDisplay(disp));
display_global = display;
return display;
}
示例13: registerObjects
Factory::Factory(weak_ptr<RootObject> root)
{
_root = root;
if (!root.expired() && root.lock()->getType() == "scene")
_isScene = true;
registerObjects();
}
示例14: Add
void TimeOutTimer::Add(weak_ptr<TermSession> ts)
{
shared_ptr<TermSession> sp_ts(ts.lock());
if (sp_ts) {
MutexLock lock(mutex_);
termsession_list_[sp_ts->Id()] = sp_ts;
}
}
示例15: load
void load( Archive& archive, int mode, const char* name, weak_ptr<Type>& object )
{
SWEET_ASSERT( mode == MODE_REFERENCE );
SWEET_ASSERT( object.lock() == ptr<Type>() );
ObjectGuard<Archive> guard( archive, name, 0, MODE_REFERENCE );
archive.reference( archive.get_address(), reinterpret_cast<void**>(&object), &resolver<weak_ptr<Type> >::resolve );
}