comparison 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
comparison
equal deleted inserted replaced
97:675cb8d5e8a7 98:99cbe2b57530
16 struct event { 16 struct event {
17 struct timeval time; 17 struct timeval time;
18 double data[4]; 18 double data[4];
19 }; 19 };
20 20
21 /* message */ 21 /* message buffer */
22 static char message[1024]; 22 static char messages[256][16];
23 static unsigned int messageid = 0;
23 24
24 #define SendMessage(threadId, ...) \ 25 #define SendMessage(threadId, ...) \
25 do { \ 26 do { \
26 snprintf(message, sizeof(message) - 1, ##__VA_ARGS__); \ 27 char *message = messages[messageid++ % 16]; \
27 PostDeferredCallToThread(MessageCB, message, threadId); \ 28 snprintf(message, sizeof(message), ##__VA_ARGS__); \
29 PostDeferredCallToThread(MessageCB, message, threadId); \
28 } while (0) 30 } while (0)
29 31
30
31 #endif 32 #endif