mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Use wpi::mutex instead of std::mutex. (#730)
This uses a priority-aware mutex on Linux platforms. Fixes #729.
This commit is contained in:
@@ -65,7 +65,7 @@ static std::string MakeStreamValue(llvm::StringRef address, int port) {
|
||||
|
||||
std::shared_ptr<nt::NetworkTable> CameraServer::GetSourceTable(
|
||||
CS_Source source) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
return m_tables.lookup(source);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ std::vector<std::string> CameraServer::GetSourceStreamValues(CS_Source source) {
|
||||
}
|
||||
|
||||
void CameraServer::UpdateStreamValues() {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
// Over all the sinks...
|
||||
for (const auto& i : m_sinks) {
|
||||
CS_Status status = 0;
|
||||
@@ -338,7 +338,7 @@ CameraServer::CameraServer()
|
||||
// Create subtable for the camera
|
||||
auto table = m_publishTable->GetSubTable(event.name);
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_tables.insert(std::make_pair(event.sourceHandle, table));
|
||||
}
|
||||
llvm::SmallString<64> buf;
|
||||
@@ -591,7 +591,7 @@ void CameraServer::StartAutomaticCapture(const cs::VideoSource& camera) {
|
||||
cs::CvSink CameraServer::GetVideo() {
|
||||
cs::VideoSource source;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
if (m_primarySourceName.empty()) {
|
||||
wpi_setWPIErrorWithContext(CameraServerError, "no camera available");
|
||||
return cs::CvSink{};
|
||||
@@ -611,7 +611,7 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
|
||||
name += camera.GetName();
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto it = m_sinks.find(name);
|
||||
if (it != m_sinks.end()) {
|
||||
auto kind = it->second.GetKind();
|
||||
@@ -635,7 +635,7 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
|
||||
cs::CvSink CameraServer::GetVideo(llvm::StringRef name) {
|
||||
cs::VideoSource source;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto it = m_sources.find(name);
|
||||
if (it == m_sources.end()) {
|
||||
llvm::SmallString<64> buf;
|
||||
@@ -659,7 +659,7 @@ cs::CvSource CameraServer::PutVideo(llvm::StringRef name, int width,
|
||||
cs::MjpegServer CameraServer::AddServer(llvm::StringRef name) {
|
||||
int port;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
port = m_nextPort++;
|
||||
}
|
||||
return AddServer(name, port);
|
||||
@@ -672,19 +672,19 @@ cs::MjpegServer CameraServer::AddServer(llvm::StringRef name, int port) {
|
||||
}
|
||||
|
||||
void CameraServer::AddServer(const cs::VideoSink& server) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_sinks.emplace_second(server.GetName(), server);
|
||||
}
|
||||
|
||||
void CameraServer::RemoveServer(llvm::StringRef name) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_sinks.erase(name);
|
||||
}
|
||||
|
||||
cs::VideoSink CameraServer::GetServer() {
|
||||
llvm::SmallString<64> name;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
if (m_primarySourceName.empty()) {
|
||||
wpi_setWPIErrorWithContext(CameraServerError, "no camera available");
|
||||
return cs::VideoSink{};
|
||||
@@ -696,7 +696,7 @@ cs::VideoSink CameraServer::GetServer() {
|
||||
}
|
||||
|
||||
cs::VideoSink CameraServer::GetServer(llvm::StringRef name) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
auto it = m_sinks.find(name);
|
||||
if (it == m_sinks.end()) {
|
||||
llvm::SmallString<64> buf;
|
||||
@@ -710,18 +710,18 @@ cs::VideoSink CameraServer::GetServer(llvm::StringRef name) {
|
||||
|
||||
void CameraServer::AddCamera(const cs::VideoSource& camera) {
|
||||
std::string name = camera.GetName();
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
if (m_primarySourceName.empty()) m_primarySourceName = name;
|
||||
m_sources.emplace_second(name, camera);
|
||||
}
|
||||
|
||||
void CameraServer::RemoveCamera(llvm::StringRef name) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
m_sources.erase(name);
|
||||
}
|
||||
|
||||
void CameraServer::SetSize(int size) {
|
||||
std::lock_guard<std::mutex> lock(m_mutex);
|
||||
std::lock_guard<wpi::mutex> lock(m_mutex);
|
||||
if (m_primarySourceName.empty()) return;
|
||||
auto it = m_sources.find(m_primarySourceName);
|
||||
if (it == m_sources.end()) return;
|
||||
|
||||
Reference in New Issue
Block a user