本文整理汇总了C++中Sequence::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Sequence::add方法的具体用法?C++ Sequence::add怎么用?C++ Sequence::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sequence
的用法示例。
在下文中一共展示了Sequence::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spawn
// The test verifies that callbacks are properly serialized by the
// Sequence object.
TEST(SequenceTest, Serialize)
{
TestProcess process;
spawn(process);
Sequence sequence;
Future<Nothing> bar = FUTURE_DISPATCH(_, &TestProcess::bar);
lambda::function<Future<Nothing>(void)> f;
f = defer(process, &TestProcess::foo);
sequence.add(f);
f = defer(process, &TestProcess::bar);
sequence.add(f);
// Flush the event queue to make sure that if the method 'bar' could
// have been invoked, the future 'bar' would be satisfied before the
// pending check below.
Clock::pause();
Clock::settle();
Clock::resume();
EXPECT_TRUE(bar.isPending());
process.promise.set(Nothing());
AWAIT_READY(bar);
terminate(process);
wait(process);
}
示例2: spawn
// The test verifies the semantics of deleting the Sequence object,
// which will result in all pending callbacks being discarded.
TEST(SequenceTest, DiscardAll)
{
DiscardProcess process;
spawn(process);
Sequence* sequence = new Sequence();
lambda::function<Future<Nothing>(void)> f;
f = defer(process, &DiscardProcess::func0);
Future<Nothing> f0 = sequence->add(f);
f = defer(process, &DiscardProcess::func1);
Future<Nothing> f1 = sequence->add(f);
f = defer(process, &DiscardProcess::func2);
Future<Nothing> f2 = sequence->add(f);
f = defer(process, &DiscardProcess::func3);
Future<Nothing> f3 = sequence->add(f);
EXPECT_CALL(process, func1())
.Times(0);
EXPECT_CALL(process, func2())
.Times(0);
EXPECT_CALL(process, func3())
.Times(0);
// Flush the event queue to make sure that all callbacks have been
// added to the sequence.
Clock::pause();
Clock::settle();
Clock::resume();
// This should cancel all pending callbacks.
delete sequence;
// Start the sequence of calls.
process.promise.set(Nothing());
AWAIT_READY(f0);
AWAIT_DISCARDED(f1);
AWAIT_DISCARDED(f2);
AWAIT_DISCARDED(f3);
terminate(process);
wait(process);
}
示例3: state
Sequence<StructInfo> StructParser::parseStructData(ParsingContext &context, String raw) {
Sequence<StructInfo> ret;
ParseState state(raw, context);
while (advanceToStruct(state)) {
ret.add(parseStruct(state));
}
return ret;
}
示例4: main
int main() {
Sequence s;
for (size_t i = 0; i < 6; ++i)
s.add(i);
s.display();
cout << "=========="<<endl;
s.reset();
for (size_t i = 0; i < 3; ++i)
s.next();
s.add(42);
s.display();
cout << "=========="<<endl;
s.reset();
for (size_t i = 0; i < 2; ++i)
s.next();
s.remove();
s.display();
cout << "=========="<<endl;
s.clear();
s.display();
cout << "=========="<<endl;
}
示例5: if
void
Sequence_Widget::set ( Log_Entry &e )
{
for ( int i = 0; i < e.size(); ++i )
{
const char *s, *v;
e.get( i, &s, &v );
if ( ! strcmp( s, ":start" ) )
_r->start = atoll( v );
// else if ( ! strcmp( s, ":offset" ) )
// _r->offset = atoll( v );
// else if ( ! strcmp( s, ":length" ) )
// _r->length = atoll( v );
else if ( ! strcmp( s, ":selected" ) )
{
if ( atoi( v ) )
select();
else
deselect();
}
else if ( ! strcmp( s, ":sequence" ) )
{
int i;
sscanf( v, "%X", &i );
Sequence *t = (Sequence*)Loggable::find( i );
ASSERT( t, "No such object ID (%s)", v );
t->add( this );
}
// else
// e.erase( i );
}
if ( _sequence )
{
_sequence->handle_widget_change( _r->start, _r->length );
_sequence->damage( FL_DAMAGE_USER1 );
}
}