Difference between revisions of "Truxton etl set thread safe"
Jump to navigation
Jump to search
(Created page with "This API tells Truxton that your code is designed to be thread-safe. =Syntax= <syntaxhighlight lang="C"> void truxton_etl_set_thread_safe( uint64_t etl_handle, uint16_t threa...") |
|||
| Line 3: | Line 3: | ||
=Syntax= | =Syntax= | ||
<syntaxhighlight lang="C"> | <syntaxhighlight lang="C"> | ||
| − | void truxton_etl_set_thread_safe( uint64_t etl_handle, uint16_t thread_safe ) | + | void truxton_etl_set_thread_safe( uint64_t etl_handle, uint16_t thread_safe ); |
</syntaxhighlight> | </syntaxhighlight> | ||
=Parameters= | =Parameters= | ||
==<code>etl_handle</code>== | ==<code>etl_handle</code>== | ||
| − | |||
The handle created by the [[truxton_etl_create]] call. | The handle created by the [[truxton_etl_create]] call. | ||
| Line 20: | Line 19: | ||
=Sample= | =Sample= | ||
| − | |||
<syntaxhighlight lang="C" highlight="16"> | <syntaxhighlight lang="C" highlight="16"> | ||
#include <TruxtonCAPI.h> | #include <TruxtonCAPI.h> | ||
Revision as of 06:51, 10 June 2020
This API tells Truxton that your code is designed to be thread-safe.
Syntax
void truxton_etl_set_thread_safe( uint64_t etl_handle, uint16_t thread_safe );
Parameters
etl_handle
The handle created by the truxton_etl_create call.
thread_safe
When set to a non-zero value, it will tell Truxton that your code is written in a thread-safe manner. Calling this API with zero tells Truxton that you are a single-threaded application.
Remarks
By default, Truxton assumes that ETL processes are single threaded and not thread-safe.
Sample
#include <TruxtonCAPI.h>
void main( void )
{
char file_id[ 65 ];
int exit_loop = 0;
uint64_t message = 0;
uint64_t app = truxton_etl_create();
truxton_etl_set_application_name( app, "Sample C ETL" );
truxton_etl_set_stage_number( app, 42 );
truxton_etl_set_queue_name( app, "SampleC" );
truxton_etl_set_thread_safe( app, 0 );
while( exit_loop == 0 )
{
message = truxton_etl_get_message( app );
if ( message != 0 )
{
// Do something with the message
memset( file_id, 0x00, sizeof( file_id ) );
truxton_message_get_file_id( message, file_id, sizeof( file_id ) );
printf( "Received file id %s\n", file_id );
truxton_message_destroy( message );
}
else
{
exit_loop = 1;
}
}
truxton_etl_destroy( app );
}