• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ defer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中defer函数的典型用法代码示例。如果您正苦于以下问题:C++ defer函数的具体用法?C++ defer怎么用?C++ defer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了defer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: data_address

void data_address(TTPtr self, t_symbol *address)
{
	WrappedModularInstancePtr	x = (WrappedModularInstancePtr)self;
	
	// Avoid succession of address changes
    if (!EXTRA->changingAddress) {
        
        EXTRA->changingAddress = YES;
        
        // filter repetitions
        if (!(x->arrayAddress == TTAddress(address->s_name))) {
            
            if (!x->iterateInternals) {
                
                // unregister internals
                wrappedModularClass_unregister(x);
                
                x->arraySize = 0;

                // rebuild internals
                defer(self,(method)data_new_address, address, 0, NULL);
                
                // for array mode : output the array once afterward
                if (x->arrayAttrFormat == gensym("array")) {
                    
                    TTValue     array;
                    t_symbol	*msg;
                    long		argc = 0;
                    t_atom		*argv = NULL;
                    TTBoolean	shifted = NO;
                    
                    data_edit_array(self, array);
                    
                    jamoma_ttvalue_to_typed_Atom(array, &msg, &argc, &argv, shifted);
                    
                    // avoid blank before data
                    if (msg == _sym_nothing)
                        outlet_atoms(x->outlets[data_out], argc, argv);
                    else
                        outlet_anything(x->outlets[data_out], msg, argc, argv);
                    
                    if (shifted)
                        argv--;
                    sysmem_freeptr(argv);
                }
            }
        }
        
        EXTRA->changingAddress = NO;
        return;
	}
	
    object_error((t_object*)x, "can't change to %s address. Please defer low", address->s_name);
}
开发者ID:avilleret,项目名称:JamomaMax,代码行数:54,代码来源:j.parameter_array.cpp


示例2: qDebug

void DesktopConnector::jsConnectorReadySlot()
{
    // at this point it's safe to start using setState as the javascript
    // connector has registered to listen for the signal
    qDebug() << "JS Connector is ready!!!!";

    // time to call the initialize callback
    defer( std::bind( m_initializeCallback, true));

//    m_initializeCallback(true);
}
开发者ID:Astroua,项目名称:CARTAvis,代码行数:11,代码来源:DesktopConnector.cpp


示例3: JLOG

void Waiter::wait()
{
    if (proceeder.unique())
    {
        JLOG("everything done, nothing to do");
        return;
    }
    defer([this] {
        auto toDestroy = std::move(proceeder);
    });
    init0();
}
开发者ID:Scardonian,项目名称:Synca,代码行数:12,代码来源:core.cpp


示例4: irphase_process

void irphase_process (t_irphase *x, t_symbol *target, t_symbol *source, double phase, double time_mul, t_phase_type mode)
{
	t_atom args[5];

	atom_setsym(args + 0, target);
	atom_setsym(args + 1, source);
	atom_setfloat(args + 2, phase);
	atom_setfloat(args + 3, time_mul);
	atom_setlong(args + 4, mode);
	
	defer(x, (method) irphase_process_internal, 0, 5, args);
}
开发者ID:EQ4,项目名称:HISSTools_Impulse_Response_Toolbox,代码行数:12,代码来源:irphase~.c


示例5: defer

TCResult ast::EnumDefn::typecheck(sst::TypecheckState* fs, fir::Type* infer, const TypeParamMap_t& gmaps)
{
	fs->pushLoc(this);
	defer(fs->popLoc());

	auto tcr = this->generateDeclaration(fs, infer, gmaps);
	if(tcr.isParametric())  return tcr;
	else if(tcr.isError())  error(this, "failed to generate declaration for enum '%s'", this->name);

	auto defn = dcast(sst::EnumDefn, tcr.defn());
	iceAssert(defn);

	auto oldscope = fs->getCurrentScope();
	fs->teleportToScope(defn->id.scope);
	fs->pushTree(defn->id.name);

	if(this->memberType)	defn->memberType = fs->convertParserTypeToFIR(this->memberType);
	else					defn->memberType = fir::Type::getInt64();

	auto ety = fir::EnumType::get(defn->id, defn->memberType);

	size_t index = 0;
	for(auto cs : this->cases)
	{
		sst::Expr* val = 0;
		if(cs.value)
		{
			iceAssert(defn->memberType);
			val = cs.value->typecheck(fs, defn->memberType).expr();

			if(val->type != defn->memberType)
				error(cs.value, "mismatched type in enum case value; expected type '%s', but found type '%s'", defn->memberType, val->type);
		}

		auto ecd = util::pool<sst::EnumCaseDefn>(cs.loc);
		ecd->id = Identifier(cs.name, IdKind::Name);
		ecd->id.scope = fs->getCurrentScope();
		ecd->type = ety;
		ecd->parentEnum = defn;
		ecd->val = val;
		ecd->index = index++;

		defn->cases[cs.name] = ecd;
		fs->stree->addDefinition(cs.name, ecd);
	}

	defn->type = ety;

	fs->popTree();
	fs->teleportToScope(oldscope);

	return TCResult(defn);
}
开发者ID:flax-lang,项目名称:flax,代码行数:53,代码来源:enums.cpp


示例6: LCD_linesegment

void LCD_linesegment(Lcd *x, long fromx, long fromy, long tox, long toy, long color)
{	
	Atom a[5];
	
	EnterCallback();
	SETLONG(a,fromx);
	SETLONG(a+1,fromy);
	SETLONG(a+2,tox);
	SETLONG(a+3,toy);
	SETLONG(a+4,color);
	defer(x,(method)LCD_dolinesegment,0L,5,a);
	ExitCallback();
}
开发者ID:CNMAT,项目名称:CNMAT-Externs,代码行数:13,代码来源:lcd.c


示例7: cmd_Mute

/*------------------------------------ cmd_Mute ---*/
Pvoid
cmd_Mute(QtPtr xx,
         long  muting)
{
  EnterCallback();
#if defined(TRACE_MESSAGES)
  LOG_POST_1("Mute")
#endif /* TRACE_MESSAGES */
  if (xx)
    defer(xx, reinterpret_cast<method>(deferred_Mute),
          reinterpret_cast<PSymbol>(muting), 0, NULL_PTR);
  ExitMaxMessageHandler()
} /* cmd_Mute */
开发者ID:opendragon,项目名称:Max_Objects,代码行数:14,代码来源:qt_Mute.c


示例8: QWidget

MirrorWidget::MirrorWidget(Aqpm::Configuration::MirrorType type, QWidget *parent)
        : QWidget(parent)
        , m_ui(new Ui::MirrorWidget)
        , m_type(type)
{
    m_ui->setupUi(this);

    reloadMirrors();

    connect(m_ui->deferButton, SIGNAL(clicked()), this, SIGNAL(defer()));
    connect(m_ui->preferButton, SIGNAL(clicked()), this, SIGNAL(prefer()));
    connect(m_ui->removeButton, SIGNAL(clicked()), this, SIGNAL(remove()));
}
开发者ID:drf,项目名称:shaman1,代码行数:13,代码来源:MirrorWidget.cpp


示例9: LCD_frameRect

void LCD_frameRect(Lcd *x, long left, long top, long right, long bottom, long color)
{	
	Atom a[5];
	
	EnterCallback();
	SETLONG(a,left);
	SETLONG(a+1,top);
	SETLONG(a+2,right);
	SETLONG(a+3,bottom);
	SETLONG(a+4,color);
	defer(x,(method)LCD_doframeRect,0L,5,a);
	ExitCallback();
}
开发者ID:CNMAT,项目名称:CNMAT-Externs,代码行数:13,代码来源:lcd.c


示例10: acquire

    Future<Nothing> acquire()
    {
        if (!promises.empty()) {
            // Need to wait for others to get permits first.
            Promise<Nothing>* promise = new Promise<Nothing>();
            promises.push_back(promise);
            return promise->future()
                   .onDiscard(defer(self(), &Self::discard, promise->future()));
        }

        if (timeout.remaining() > Seconds(0)) {
            // Need to wait a bit longer, but first one in the queue.
            Promise<Nothing>* promise = new Promise<Nothing>();
            promises.push_back(promise);
            delay(timeout.remaining(), self(), &Self::_acquire);
            return promise->future()
                   .onDiscard(defer(self(), &Self::discard, promise->future()));
        }

        // No need to wait!
        timeout = Seconds(1) / permitsPerSecond;
        return Nothing();
    }
开发者ID:abhishekamralkar,项目名称:mesos,代码行数:23,代码来源:limiter.hpp


示例11: detect

  Future<Option<MasterInfo>> detect(
      const Option<MasterInfo>& previous = None())
  {
    if (leader != previous) {
      return leader;
    }

    Promise<Option<MasterInfo>>* promise = new Promise<Option<MasterInfo>>();

    promise->future()
      .onDiscard(defer(self(), &Self::discard, promise->future()));

    promises.insert(promise);
    return promise->future();
  }
开发者ID:AbheekG,项目名称:mesos,代码行数:15,代码来源:standalone.cpp


示例12: Failure

Future<Future<Nothing>> LeaderContenderProcess::contend()
{
  if (contending.isSome()) {
    return Failure("Cannot contend more than once");
  }

  LOG(INFO) << "Joining the ZK group";
  candidacy = group->join(data, label);
  candidacy
    .onAny(defer(self(), &Self::joined));

  // Okay, we wait and see what unfolds.
  contending = new Promise<Future<Nothing>>();
  return contending.get()->future();
}
开发者ID:GrovoLearning,项目名称:mesos,代码行数:15,代码来源:contender.cpp


示例13: LOG

void LeaderContenderProcess::cancel()
{
  if (!candidacy.isReady()) {
    // Nothing to cancel.
    if (withdrawing.isSome()) {
      withdrawing.get()->set(false);
    }
    return;
  }

  LOG(INFO) << "Now cancelling the membership: " << candidacy->id();

  group->cancel(candidacy.get())
    .onAny(defer(self(), &Self::cancelled, lambda::_1));
}
开发者ID:GrovoLearning,项目名称:mesos,代码行数:15,代码来源:contender.cpp


示例14: glCreateProgram

bool ShaderProgram::attachShaderFromMemory(ShaderType type,
                                           const std::string& source)
{
	if (!handle)
		handle = glCreateProgram();

	const char* shaderSource{source.c_str()};

	u32 shader{0};
	if (type == ShaderType::Vertex)
		shader = glCreateShader(GL_VERTEX_SHADER);
	else if (type == ShaderType::Fragment)
		shader = glCreateShader(GL_FRAGMENT_SHADER);

	glShaderSource(shader, 1, &shaderSource, nullptr);
	glCompileShader(shader);

	s32 status;
	glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
	if (status == false)
	{
		std::string msg;
		if (type == ShaderType::Vertex)
			msg = "Compile failure in vertex shader: \n";
		else if (type == ShaderType::Fragment)
			msg = "Compile failure in fragment shader: \n";

		s32 infoLogLength;
		glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);

		char* strInfoLog{new char[infoLogLength + 1]};
		defer(delete[] strInfoLog);

		glGetShaderInfoLog(shader, infoLogLength, nullptr, strInfoLog);

		msg.append(strInfoLog);
		msg.append("\n");
		errorLog.append(msg);

		glDeleteShader(shader);

		return false;
	}

	glAttachShader(handle, shader);

	return true;
}
开发者ID:Kitsune001,项目名称:Dunjun,代码行数:48,代码来源:ShaderProgram.cpp


示例15: findViewInfo

void DesktopConnector::jsUpdateViewSlot(const QString & viewName, int width, int height)
{
    ViewInfo * viewInfo = findViewInfo( viewName);
    if( ! viewInfo) {
        qWarning() << "Received update for unknown view " << viewName;
        return;
    }

    IView * view = viewInfo-> view;
    viewInfo-> clientSize = QSize( width, height);

    defer([this,view,viewInfo](){
        view-> handleResizeRequest( viewInfo-> clientSize);
        refreshView( view);
    });
}
开发者ID:Astroua,项目名称:CARTAvis,代码行数:16,代码来源:DesktopConnector.cpp


示例16: load_image

  Image load_image( const char* filename )
  {
    i32 width;
    i32 height;
    i32 format;

    // Using NULL because stbi_load takes an integer and nullptr
    // has type nullptr_t.
    u8* pixels = stbi_load( filename, &width, &height, &format, 0 );
    defer( stbi_image_free( pixels ) );

    if ( !pixels )
      throw std::runtime_error( stbi_failure_reason() );

    return load_image( width, height, (ImageFormat)format, pixels );
  }
开发者ID:for-all-mankind,项目名称:game-engine,代码行数:16,代码来源:Image.cpp


示例17: main

int
main()
{
	session_t sess;
	datum id;
	time_t create_time, last_seen;
	bool do_allow;
	char *reason;

	openlog("dorian/query", LOG_PID, LOG_MAIL);
	for (;;) {
		do_allow = false;
		if ((sess = sess_req(stdin)) == NULL)
			break;

		/* white listing */
		for_each(i, whitelist_prefix)
			if (!strncasecmp(whitelist_prefix[i], sess->attr[Krecipient],
						strlen(whitelist_prefix[i]))) {
				do_allow = true;
				reason = "whitelist address";
				break;
			}

		if (!do_allow) {
			sess_derive_key(sess, &id);
			{
				if (seen(id, &create_time, &last_seen)) {
					if (create_time < expired()) {
						bump(id, create_time);
						do_allow = true;
						reason = "in database";
					}
				} else
					add(id);
			}
			free(id.dptr);
		}
		sess_free(&sess);
		if (do_allow)
			allow(reason);
		else
			defer();
	}
	closelog();
	return 0;
}
开发者ID:blundellc,项目名称:dorian,代码行数:47,代码来源:grey.c


示例18: cmd_Rate

/*------------------------------------ cmd_Rate ---*/
Pvoid
cmd_Rate(QtPtr xx,
         long  numerator,
         long  denominator)
{
  Atom avRate[2];

  EnterCallback();
#if defined(TRACE_MESSAGES)
  LOG_POST_1("Rate")
#endif /* TRACE_MESSAGES */
  SETLONG(avRate, numerator);
  SETLONG(avRate + 1, denominator);
  if (xx)
    defer(xx, reinterpret_cast<method>(deferred_Rate), NULL_PTR, 2, avRate);
  ExitMaxMessageHandler()
} /* cmd_Rate */
开发者ID:opendragon,项目名称:Max_Objects,代码行数:18,代码来源:qt_Rate.c


示例19: find

/**
Removes a client from the list.
*/
bool Clients::remove(int remid){
    iterator it = find(remid);
    if (it != end()){
        Client* cl = readyiter->second;
        cl->clearPlayers();
        mute || cout << ticks() << ": client #" << cl->id << " left" << endl;

        if (cl->game != 0){
            cl->game->removeClient(cl->id);
            cl->game = 0;
        }

        defer(cl->id);
        return true;
    }
    return false;
}
开发者ID:blaf,项目名称:ditchers,代码行数:20,代码来源:data.hpp


示例20: shaderSourceFromFile

INTERNAL String shaderSourceFromFile(const String& filename)
{
	String filePath = BaseDirectory::Shaders + filename;

	std::ifstream file;
	file.open(cString(filePath), std::ios::in | std::ios::binary);
	if (!file.is_open())
	{
		panic("Failed to open shader file: " + filePath);
		return {};
	}
	defer(file.close());

	String output;

	String line;

	while (file.good())
	{
		getline(file, line);
		line = Strings::trimSpace(line);

		if (Strings::hasPrefix(line, "#include"))
		{
			String includeFilename = substring(line, 8, len(line));
			includeFilename = Strings::trimSpace(includeFilename);
			includeFilename = Strings::trim(includeFilename, "\"");

			if (len(includeFilename) > 0)
			{
				// Recursively append source of header file and append header
				// extension
				const String& withExt = cString(includeFilename + ".head.glsl");
				append(output, shaderSourceFromFile(withExt));
			}
		}
		else
		{
			append(output, line);
		}
		append(output, '\n'); // Append a *nix newline
	}

	return output;
}
开发者ID:UIKit0,项目名称:Dunjun,代码行数:45,代码来源:ShaderProgram.cpp



注:本文中的defer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ defer_bh函数代码示例发布时间:2022-05-30
下一篇:
C++ defaultsToParam_函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap