Change hal sim to use spinlocks (#1291)

This makes callback registration completely thread safe.

This patch also uses templates and macros to dramatically reduce the amount of
manual boilerplate.
This commit is contained in:
Peter Johnson
2018-09-03 16:08:07 -07:00
committed by GitHub
parent 67b1c85315
commit c0ff6198b3
65 changed files with 1305 additions and 7639 deletions

View File

@@ -28,7 +28,7 @@ HAL_CompressorHandle HAL_InitializeCompressor(int32_t module, int32_t* status) {
// As compressors can have unlimited objects, just create a
// handle with the module number as the index.
SimPCMData[module].SetCompressorInitialized(true);
SimPCMData[module].compressorInitialized = true;
return (HAL_CompressorHandle)createHandle(static_cast<int16_t>(module),
HAL_HandleEnum::Compressor, 0);
}
@@ -46,7 +46,7 @@ HAL_Bool HAL_GetCompressor(HAL_CompressorHandle compressorHandle,
return false;
}
return SimPCMData[index].GetCompressorOn();
return SimPCMData[index].compressorOn;
}
void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressorHandle,
@@ -58,7 +58,7 @@ void HAL_SetCompressorClosedLoopControl(HAL_CompressorHandle compressorHandle,
return;
}
SimPCMData[index].SetClosedLoopEnabled(value);
SimPCMData[index].closedLoopEnabled = value;
}
HAL_Bool HAL_GetCompressorClosedLoopControl(
@@ -70,7 +70,7 @@ HAL_Bool HAL_GetCompressorClosedLoopControl(
return false;
}
return SimPCMData[index].GetClosedLoopEnabled();
return SimPCMData[index].closedLoopEnabled;
}
HAL_Bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressorHandle,
@@ -82,7 +82,7 @@ HAL_Bool HAL_GetCompressorPressureSwitch(HAL_CompressorHandle compressorHandle,
return false;
}
return SimPCMData[index].GetPressureSwitch();
return SimPCMData[index].pressureSwitch;
}
double HAL_GetCompressorCurrent(HAL_CompressorHandle compressorHandle,
@@ -94,7 +94,7 @@ double HAL_GetCompressorCurrent(HAL_CompressorHandle compressorHandle,
return 0;
}
return SimPCMData[index].GetCompressorCurrent();
return SimPCMData[index].compressorCurrent;
}
HAL_Bool HAL_GetCompressorCurrentTooHighFault(
HAL_CompressorHandle compressorHandle, int32_t* status) {