Skip to content

Commit

Permalink
extras: rename m_lock to m_fd_lock because its only purpose is to pro…
Browse files Browse the repository at this point in the history
…tect the set of watched file descriptors

Signed-off-by: Johannes Meyer <johannes@intermodalics.eu>
  • Loading branch information
meyerj committed Oct 24, 2019
1 parent 1307306 commit 03e8b76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions rtt/extras/FileDescriptorActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void FileDescriptorActivity::setTimeout_us(int timeout_us)
}
}
void FileDescriptorActivity::watch(int fd)
{ RTT::os::MutexLock lock(m_lock);
{ RTT::os::MutexLock lock(m_fd_lock);
if (fd < 0)
{
log(Error) << "negative file descriptor given to FileDescriptorActivity::watch" << endlog();
Expand All @@ -194,13 +194,13 @@ void FileDescriptorActivity::watch(int fd)
triggerUpdateSets();
}
void FileDescriptorActivity::unwatch(int fd)
{ RTT::os::MutexLock lock(m_lock);
{ RTT::os::MutexLock lock(m_fd_lock);
m_watched_fds.erase(fd);
FD_CLR(fd, &m_fd_set);
triggerUpdateSets();
}
void FileDescriptorActivity::clearAllWatches()
{ RTT::os::MutexLock lock(m_lock);
{ RTT::os::MutexLock lock(m_fd_lock);
m_watched_fds.clear();
FD_ZERO(&m_fd_set);
triggerUpdateSets();
Expand All @@ -226,7 +226,7 @@ bool FileDescriptorActivity::hasError() const
bool FileDescriptorActivity::hasTimeout() const
{ return m_has_timeout; }
bool FileDescriptorActivity::isWatched(int fd) const
{ RTT::os::MutexLock lock(m_lock);
{ RTT::os::MutexLock lock(m_fd_lock);
return FD_ISSET(fd, &m_fd_set); }

bool FileDescriptorActivity::start()
Expand Down Expand Up @@ -308,7 +308,7 @@ void FileDescriptorActivity::loop()
while(true)
{
int max_fd;
{ RTT::os::MutexLock lock(m_lock);
{ RTT::os::MutexLock lock(m_fd_lock);
if (m_watched_fds.empty())
max_fd = pipe;
else
Expand Down
2 changes: 1 addition & 1 deletion rtt/extras/FileDescriptorActivity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace RTT { namespace extras {
int m_timeout_us; //! timeout in microseconds
Seconds m_period; //! intended period
/** Lock that protects the access to m_fd_set and m_watched_fds */
mutable RTT::os::Mutex m_lock;
mutable RTT::os::Mutex m_fd_lock;
fd_set m_fd_set;
fd_set m_fd_work;
bool m_has_error;
Expand Down

0 comments on commit 03e8b76

Please # to comment.