Commit da025a9d authored by Jonas Stienen's avatar Jonas Stienen

Adding vista ticker test (will substitute ITATimer as a cross-platform ticker)

parent 1900a522
......@@ -30,3 +30,6 @@ if( ITA_BASE_WITH_SNDFILE )
set_property( TARGET SampleFrameTest PROPERTY FOLDER "ITACoreLibs/Tests/ITABase" )
endif( )
add_subdirectory( "VistaTests" )
cmake_minimum_required( VERSION 2.8 )
project( VistaTests )
list( APPEND CMAKE_MODULE_PATH "$ENV{VISTA_CMAKE_COMMON}" )
include( VistaCommon )
vista_use_package( VistaCoreLibs REQUIRED COMPONENTS VistaInterProcComm FIND_DEPENDENCIES )
add_executable( VistaTickerTest VistaTickerTest.cpp )
target_link_libraries( VistaTickerTest ${VISTA_USE_PACKAGE_LIBRARIES} )
vista_configure_app( VistaTickerTest )
vista_install( VistaTickerTest )
vista_create_default_info_file( VistaTickerTest )
set_property( TARGET VistaTickerTest PROPERTY FOLDER "ITACoreLibs/Tests/Vista" )
#include <VistaInterProcComm/Concurrency/VistaTicker.h>
#include <VistaBase/VistaTimeUtils.h>
#include <iostream>
using namespace std;
class TickerCallback : public VistaTicker::AfterPulseFunctor
{
public:
inline bool operator()()
{
cout << "Ticker callback called" << endl;
return true;
};
int nGranularityMS;
};
int main( int, char** )
{
VistaTicker oTicker;
TickerCallback oCallback;
oCallback.nGranularityMS = oTicker.GetGranularity();
VistaTicker::TriggerContext oTickerContext( oTicker.GetGranularity(), true );
oTicker.SetAfterPulseFunctor( &oCallback );
oTicker.AddTrigger( &oTickerContext );
oTicker.StartTicker();
VistaTimeUtils::Sleep( int( 5*1e3 ) );
oTicker.StopTicker();
oTicker.RemTrigger( &oTickerContext );
oTicker.SetAfterPulseFunctor( NULL ); // Otherwise Ticker will delete callback instance
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment