本文整理汇总了C++中WorkQueue::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkQueue::SetName方法的具体用法?C++ WorkQueue::SetName怎么用?C++ WorkQueue::SetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkQueue
的用法示例。
在下文中一共展示了WorkQueue::SetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateObject
bool ConfigObjectUtility::CreateObject(const Type::Ptr& type, const String& fullName,
const String& config, const Array::Ptr& errors, const Array::Ptr& diagnosticInformation)
{
{
boost::mutex::scoped_lock lock(ConfigPackageUtility::GetStaticMutex());
if (!ConfigPackageUtility::PackageExists("_api")) {
ConfigPackageUtility::CreatePackage("_api");
String stage = ConfigPackageUtility::CreateStage("_api");
ConfigPackageUtility::ActivateStage("_api", stage);
}
}
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(type, fullName);
if (item) {
errors->Add("Object '" + fullName + "' already exists.");
return false;
}
String path = GetObjectConfigPath(type, fullName);
Utility::MkDirP(Utility::DirName(path), 0700);
if (Utility::PathExists(path)) {
errors->Add("Cannot create object '" + fullName + "'. Configuration file '" + path + "' already exists.");
return false;
}
std::ofstream fp(path.CStr(), std::ofstream::out | std::ostream::trunc);
fp << config;
fp.close();
std::unique_ptr<Expression> expr = ConfigCompiler::CompileFile(path, String(), "_api");
try {
ActivationScope ascope;
ScriptFrame frame(true);
expr->Evaluate(frame);
expr.reset();
WorkQueue upq;
upq.SetName("ConfigObjectUtility::CreateObject");
std::vector<ConfigItem::Ptr> newItems;
/* Disable logging for object creation, but do so ourselves later on. */
if (!ConfigItem::CommitItems(ascope.GetContext(), upq, newItems, true) || !ConfigItem::ActivateItems(upq, newItems, true, true)) {
if (errors) {
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(path));
}
for (const boost::exception_ptr& ex : upq.GetExceptions()) {
errors->Add(DiagnosticInformation(ex, false));
if (diagnosticInformation)
diagnosticInformation->Add(DiagnosticInformation(ex));
}
}
return false;
}
ApiListener::UpdateObjectAuthority();
Log(LogInformation, "ConfigObjectUtility")
<< "Created and activated object '" << fullName << "' of type '" << type->GetName() << "'.";
} catch (const std::exception& ex) {
if (unlink(path.CStr()) < 0 && errno != ENOENT) {
BOOST_THROW_EXCEPTION(posix_error()
<< boost::errinfo_api_function("unlink")
<< boost::errinfo_errno(errno)
<< boost::errinfo_file_name(path));
}
if (errors)
errors->Add(DiagnosticInformation(ex, false));
if (diagnosticInformation)
diagnosticInformation->Add(DiagnosticInformation(ex));
return false;
}
return true;
}