ecore eina threadqueue test suite - be correct about volatile+padding

fill in the padding of mesages (10 bytes) with something so valgrinds
can be happy and use vlatiole for msgs count as the msgs num should
have been incremented already before the msg sned is done and main
thread/loop gets the msg
This commit is contained in:
Carsten Haitzler 2016-08-05 14:35:41 +09:00
parent 6b6823e5af
commit 720f17619e
1 changed files with 5 additions and 2 deletions

View File

@ -36,6 +36,7 @@ th1_do(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
usleep((rand() % 10) * 1000);
msg = eina_thread_queue_send(thq1, sizeof(Msg), &ref);
msg->value = val;
memset(msg->pad, 0x32, 10);
eina_thread_queue_send_done(thq1, ref);
if (val == 1000) break;
val++;
@ -56,8 +57,10 @@ th2_do(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
val = msg->value;
usleep((rand() % 20) * 1000);
eina_thread_queue_wait_done(thq1, ref);
msg = eina_thread_queue_send(thq2, sizeof(Msg), &ref);
msg->value = val;
memset(msg->pad, 0x32, 10);
eina_thread_queue_send_done(thq2, ref);
if (val == 1000) break;
}
@ -101,7 +104,7 @@ typedef struct
int ops[1];
} Msg2;
static int msgs = 0;
static volatile int msgs = 0;
static void
thspeed1_do(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
@ -114,8 +117,8 @@ thspeed1_do(void *data EINA_UNUSED, Ecore_Thread *th EINA_UNUSED)
msg = eina_thread_queue_wait(thq1, &ref);
if (msg)
{
eina_thread_queue_wait_done(thq1, ref);
msgs++;
eina_thread_queue_wait_done(thq1, ref);
}
if (msgs == 10000000)
{