本文整理汇总了C++中QSharedPointer::Put方法的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer::Put方法的具体用法?C++ QSharedPointer::Put怎么用?C++ QSharedPointer::Put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSharedPointer
的用法示例。
在下文中一共展示了QSharedPointer::Put方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: commitLoop
static void commitLoop(lmdbGallery * base)
{
QSharedPointer<caffe::db::Transaction> txn;
int total_count = 0;
// Acquire the lock
QMutexLocker lock(&base->dataLock);
while (true) {
// wait for data, or end signal
while(base->data.isEmpty() && !base->should_end)
base->dataWait.wait(&base->dataLock);
// If should_end, but there is still data, we need another commit
// round
if (base->should_end && base->data.isEmpty())
break;
txn = QSharedPointer<caffe::db::Transaction>(base->db->NewTransaction());
TemplateList working = base->data;
base->data.clear();
// no longer blocking dataLock
lock.unlock();
foreach(const Template &t, working) {
// add current image to transaction
caffe::Datum datum;
caffe::CVMatToDatum(t.m(), &datum);
QVariant base_label = t.file.value("Label");
QString label_str = base_label.toString();
if (!base->observedLabels.contains(label_str) )
base->observedLabels.insert(label_str, base->observedLabels.size());
datum.set_label(base->observedLabels[label_str]);
std::string out;
datum.SerializeToString(&out);
char key_cstr[256];
int len = snprintf(key_cstr, 256, "%08d_%s", total_count, qPrintable(t.file.name));
txn->Put(std::string(key_cstr, len), out);
total_count++;
}
txn->Commit();
lock.relock();
}