I have an array of a struct defined in thread A, storing the state of some clients.
I would like to modify the states in thread B, so I pass the adress of the array over a channel.
Thread A:
Code: Select all
sscClientStateRx_t sscClientStatesRx[n];
initClientStatesRx(sscClientStatesRx, n);
unsafe{
sscToConfig <: (sscClientStateRx_t * unsafe) sscClientStatesRx;
}
Code: Select all
sscClientStateRx_t * unsafe clientStates;
unsafe{
channelToManager :> clientStates;
}
Code: Select all
case cfg_if[int i].setFilterIp(unsigned int uiRxIndex, unsigned int uiIp):
unsafe{
clientStates[uiRxIndex]->filterIp = uiIp;
}
break;
Code: Select all
case cfg_if[int i].setFilterIp(unsigned int uiRxIndex, unsigned int uiIp):
unsafe{
clientStates[uiRxIndex].filterIp = uiIp;
}
break;
another approach I saw being used somewhere else was
Code: Select all
case cfg_if[int i].setFilterIp(unsigned int uiRxIndex, unsigned int uiIp):
unsafe{
sscClientStateRx_t &clientState = clientStates[uiRxIndex];
clientState.filterIp = uiIp;
}
break;