KiCad PCB EDA Suite
MyClass Class Reference

Public Member Functions

int CountTo (int n)
 
void Run ()
 
int MyMethod (const string &arg)
 

Public Attributes

MyCoroutine cofunc
 

Detailed Description

Definition at line 8 of file coroutine_example.cpp.

Member Function Documentation

int MyClass::CountTo ( int  n)
inline

Definition at line 11 of file coroutine_example.cpp.

References cofunc.

Referenced by Run().

12  {
13  printf( "%s: Coroutine says hi. I will count from 1 to %d and yield each value.\n",
14  __FUNCTION__,
15  n );
16 
17  for( int i = 1; i <= n; i++ )
18  {
19  printf( "%s: Yielding %d\n", __FUNCTION__, i );
20  cofunc.Yield( i );
21  }
22  }
MyCoroutine cofunc
int MyClass::MyMethod ( const string &  arg)
inline

Definition at line 9 of file delegate_example.cpp.

Referenced by main().

10  {
11  printf( "MyClass(this = %p)::MyMethod() called with string '%s', length %d\n", this,
12  arg.c_str(), arg.length() );
13  return arg.length();
14  }
void MyClass::Run ( )
inline

Definition at line 24 of file coroutine_example.cpp.

References COROUTINE< ReturnType, ArgType >::Call(), cofunc, CountTo(), COROUTINE< ReturnType, ArgType >::Resume(), COROUTINE< ReturnType, ArgType >::ReturnValue(), and COROUTINE< ReturnType, ArgType >::Running().

Referenced by main().

25  {
27  printf( "%s: Calling coroutine that will count from 1 to 5.\n", __FUNCTION__ );
28  cofunc.Call( 5 );
29 
30  while( cofunc.Running() )
31  {
32  printf( "%s: Got value: %d\n", __FUNCTION__, cofunc.ReturnValue() );
33  cofunc.Resume();
34  }
35 
36  printf( "%s: Done!\n", __FUNCTION__ );
37  }
bool Call(ArgType aArg)
Function Call()
Definition: coroutine.h:204
MyCoroutine cofunc
const ReturnType & ReturnValue() const
Function ReturnValue()
Definition: coroutine.h:269
bool Resume()
Function Resume()
Definition: coroutine.h:238
COROUTINE< int, int > MyCoroutine
int CountTo(int n)
bool Running() const
Function Running()
Definition: coroutine.h:279

Member Data Documentation

MyCoroutine MyClass::cofunc

Definition at line 39 of file coroutine_example.cpp.

Referenced by CountTo(), and Run().


The documentation for this class was generated from the following files: