Mercurial > hg > fxanalyse
view data-provider.h @ 98:99cbe2b57530
Allow up to 16 messages to pile up in the communication between threads
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Tue, 26 Mar 2013 18:20:12 +0100 |
parents | 4102fe614df2 |
children | 8b90fbba59ef |
line wrap: on
line source
#ifndef __DATA_PROVIDER_H__ #define __DATA_PROVIDER_H__ #include <future.h> /* data acquisition flag */ extern int acquiring; /* data queue */ extern CmtTSQHandle dataQueue; /* callback receiving messages in the main thread */ void CVICALLBACK MessageCB (void *callbackData); /* data acquisition event */ struct event { struct timeval time; double data[4]; }; /* message buffer */ static char messages[256][16]; static unsigned int messageid = 0; #define SendMessage(threadId, ...) \ do { \ char *message = messages[messageid++ % 16]; \ snprintf(message, sizeof(message), ##__VA_ARGS__); \ PostDeferredCallToThread(MessageCB, message, threadId); \ } while (0) #endif