当前位置: 首页>>代码示例>>C++>>正文


C++ Signal::emit方法代码示例

本文整理汇总了C++中Signal::emit方法的典型用法代码示例。如果您正苦于以下问题:C++ Signal::emit方法的具体用法?C++ Signal::emit怎么用?C++ Signal::emit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Signal的用法示例。


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

示例1: poll_inserted

void poll_inserted() {
	const auto card_present_now = sdcIsCardInserted(&SDCD1);
	if( card_present_now != card_present ) {
		card_present = card_present_now;

		Status new_status { card_present ? Status::Present : Status::NotPresent };

		if( card_present ) {
			if( sdcConnect(&SDCD1) == CH_SUCCESS ) {
				if( mount() == FR_OK ) {
					new_status = Status::Mounted;
				} else {
					new_status = Status::MountError;
				}
			} else {
				new_status = Status::ConnectError;
			}
		} else {
			sdcDisconnect(&SDCD1);
		}

		status_ = new_status;
		status_signal.emit(status_);
	}
}
开发者ID:sharebrained,项目名称:portapack-hackrf,代码行数:25,代码来源:sd_card.cpp

示例2: benchSignalEmissionGroups

// profile time for emission with 4 slots, 2 in group 0 and 2 in group 1
static void benchSignalEmissionGroups()
{
	Signal<void ( void*, uint64_t )> sigIncrement;
	sigIncrement.connect( testCounterAdd2 );
	sigIncrement.connect( testCounterAdd2 );
	sigIncrement.connect( 1, testCounterAdd2 );
	sigIncrement.connect( 1, testCounterAdd2 );

	const uint64_t startCounter = TestCounter::get();
	const uint64_t benchStart = timestampBenchmark();

	uint64_t i;
	for( i = 0; i < 1000000; i++ )
		sigIncrement.emit( nullptr, 1 );

	const uint64_t benchDone = timestampBenchmark();
	const uint64_t endCounter = TestCounter::get();

	assert( endCounter - startCounter == ( i * 4 ) );

	cout << "OK" << endl;
	cout << "\tper emission: " << double( benchDone - benchStart ) / double( i ) << "ns"
	<< ", per slot: " << double( benchDone - benchStart ) / double( i * 4 ) << "ns"
	<< endl;
}
开发者ID:AbdelghaniDr,项目名称:Cinder,代码行数:26,代码来源:SignalsBenchmark.cpp

示例3: main

int main()
{  
    Signal<void(int)> signal;
    signal.connect(anyFunc);

    signal.connect(
          [] (int num) {
             // TODO: Implement handler logic here.
          }
    );
    signal.emit( 0 );
    
    return 0;
}
开发者ID:CCJY,项目名称:coliru,代码行数:14,代码来源:main.cpp

示例4: on_tick_second

void on_tick_second() {
	signal_tick_second.emit();
}
开发者ID:CCrashBandicot,项目名称:portapack-hackrf,代码行数:3,代码来源:time.cpp

示例5: main

		int main(int argc, char **argv) {
			Signal<int(int)> sig;

			Test("disconnect non existing");
			{
				bool res;
				res = sig.disconnect(0);
				ASSERT(!res);
			}

			Test("connect");
			size_t id = sig.connect(Util::dummy);

			Test("single connection: check result");
			const int input = 100;
			auto numVal = sig.emit(input);
			auto val = sig.results();
			ASSERT(numVal == val->size());
			ASSERT(val->size() == 1);
			ASSERT((*val)[0] == Util::dummy(input));

			Test("multiple connections: check results");
			size_t id2 = sig.connect(dummy2);
			size_t id3 = sig.connect(Util::dummy);
			size_t id4 = sig.connect(dummy2);
			numVal = sig.emit(input);
			val = sig.results();
			ASSERT(numVal == val->size());
			ASSERT(val->size() == 4);
			ASSERT((*val)[0] == Util::dummy(input));
			ASSERT((*val)[1] == dummy2(input));
			ASSERT((*val)[2] == Util::dummy(input));
			ASSERT((*val)[3] == dummy2(input));

			Test("multiple connections: ask results again");
			auto val2 = sig.results();
			ASSERT(numVal == val2->size());
			ASSERT(val2->size() == 4);
			ASSERT((*val2)[0] == Util::dummy(input));
			ASSERT((*val2)[1] == dummy2(input));
			ASSERT((*val2)[2] == Util::dummy(input));
			ASSERT((*val2)[3] == dummy2(input));

			Test("disconnections");
			{
				bool res;
				res = sig.disconnect(id2);
				ASSERT(res);

				res = sig.disconnect(id);
				ASSERT(res);

				//disconnect again
				res = sig.disconnect(id);
				ASSERT(!res);

				//wrong id
				res = sig.disconnect(id + 1);
				ASSERT(!res);
			}

			return 0;
		}
开发者ID:rbouqueau,项目名称:async,代码行数:63,代码来源:signals_simple.cpp

示例6: main


//.........这里部分代码省略.........
    action->m_slotMsgM.getStaticCastFunction()( mb, nullptr );
    action->expectDynamicType( op, "MsgB" );
    action->expectStaticType( op, "Message" );

    //op = "   Invoke action m_slotMsgA with mm";
    //action->m_slotMsgA( mm ); is not a valid static cast

    op = "   Invoke action m_slotMsgA with ma";
    action->m_slotMsgA.getStaticCastFunction()( ma, nullptr );
    action->expectDynamicType( op, "MsgA" );
    action->expectStaticType( op, "MsgA" );

    op = "   Invoke action m_slotMsgA with mb";
    action->m_slotMsgA.getStaticCastFunction()( mb, nullptr );
    action->expectDynamicType( op, "MsgB" );
    action->expectStaticType( op, "MsgA" );

    //op = "   Invoke action m_slotMsgB with mm";
    //action->m_slotMsgB( mm ); is not a valid static cast

    //op = "   Invoke action m_slotMsgB with ma";
    //action->m_slotMsgB( ma ); is not a valid static cast

    op = "   Invoke action m_slotMsgB with mb";
    action->m_slotMsgB.getStaticCastFunction()( mb, nullptr );
    action->expectDynamicType( op, "MsgB" );
    action->expectStaticType( op, "MsgB" );
    cout << "Ok" << endl;


    // Note: Without links emission has no effect
    cout << "Test Signal type check : ";

    action->m_signalMsgM.emit( mm );
    action->m_signalMsgM.emit( ma );
    action->m_signalMsgM.emit( mb );

    // action->m_signalMsgA.emit( mm ); // Ok: static Error
    action->m_signalMsgA.emit( ma );
    action->m_signalMsgA.emit( mb );

    // action->m_signalMsgB.emit( mm ); // Ok: static Error
    // action->m_signalMsgB.emit( ma ); // Ok: static Error
    action->m_signalMsgB.emit( mb );

    cout << "Ok" << endl;

    cout << "Test connecting links  : ";

    try
    {
        if( Link::isConnected( "myAction::signalMsgM", "myAction::slotMsgM") )
        {
            cout << "Failed!" << endl;
            cout << "   Link myAction::signalMsgM -> myAction::slotMsgM exist." << endl;
            exit(1);
        }

        Link::connect( "myAction::signalMsgM", "myAction::slotMsgM");

        if( !Link::isConnected( "myAction::signalMsgM", "myAction::slotMsgM") )
        {
            cout << "Failed!" << endl;
            cout << "   Link myAction::signalMsgM -> myAction::slotMsgM not created." << endl;
            exit(1);
        }
开发者ID:chmike,项目名称:MPO,代码行数:67,代码来源:main.cpp


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