Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement thread-safe logging. #427

Draft
wants to merge 2 commits into
base: rolling
Choose a base branch
from

Commits on Sep 13, 2023

  1. Implement thread-safe logging.

    This commit introduces thread-safe logging to rcutils.
    In particular, what it does is to add in a read-write lock
    around accesses to the g_rcutils_logging_severities_map
    in logging.c.
    
    This enables two things:
    1. Thread-safe writes to the hash map so that get_logger_level
    and set_logger_level can be called simultaneously on two
    different threads.
    2. The ability to cache lookups during get_logger_effective_level,
    so we have to do less parsing on every log call.
    
    This introduces the concept of locking into rcutils, which
    we haven't had before.  However, this particular use seems to
    be justified, since the logging subsystem can be called outside
    of the client libraries that could possibly do this locking
    at a higher level (think about the rmw implementations, for
    instance).
    
    Note that this introduces a new pthread dependency within
    rcutils that we've not had before.
    
    Signed-off-by: Chris Lalancette <[email protected]>
    clalancette committed Sep 13, 2023
    Configuration menu
    Copy the full SHA
    70e8eaa View commit details
    Browse the repository at this point in the history
  2. Split up compilation of rwlock to separate files.

    It is much easier to follow this way.
    
    Signed-off-by: Chris Lalancette <[email protected]>
    clalancette committed Sep 13, 2023
    Configuration menu
    Copy the full SHA
    ab44fc8 View commit details
    Browse the repository at this point in the history