Graphics Reference
In-Depth Information
#ifdef NETWORK_CONTROL
//Since rendering application is C++, and the system is SISO/MISO,
// there is only one data channel to send back to controller, i.e. y.
//Note data type and container size.
ds.data[0] = 999; //Initialization value
ds.data[1] = 999;
//Clear receive buffer
dr.data[0] = 999;
dr.data[1] = 999;
for(int i = 0; i<MAX_THREADS; i++)
{
//Allocate memory for thread data.
pDataArray[i] = (PMYDATA) HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY, sizeof(MYDATA));
if(pDataArray[i] = = NULL)
{
//If the array allocation fails, the system is out of memory
//so there is no point in trying to print an error message.
//Just terminate execution.
ExitProcess(2);
}
//0 - Send, 1 - Receive
if (i = = 0)
{
hThreadArray[i] = CreateThread(
NULL, //default security attributes
0, //use default stack size
SendDataThreadFunction, //thread function name
pDataArray[i],
//argument to thread function
0,
//use default creation flags
&dwThreadIdArray[i]);
//returns the thread identifier
}
if (i = = 1)
{
hThreadArray[1] = CreateThread(
NULL, //default security attributes
0, //use default stack size
ReceiveDataThreadFunction, //thread function name
pDataArray[1],
//argument to thread function
0,
//use default creation flags
&dwThreadIdArray[1]);
//returns the thread identifier
}
//Check the return value for success.
//If CreateThread fails, terminate execution.
//This will automatically clean up threads and memory.
if (hThreadArray[i] = = NULL)
{
printf(“Error creating thread...!\n”);
ExitProcess(3);
}
Search WWH ::




Custom Search