MCPcopy Create free account
hub / github.com/apache/mesos / CheckPosixThreading

Function CheckPosixThreading

support/cpplint.py:2124–2147  ·  view source on GitHub ↗

Checks for calls to thread-unsafe functions. Much code has been originally written without consideration of multi-threading. Also, engineers are relying on their old experience; they have learned posix before threading extensions were added. These tests guide the engineers to use thread-saf

(filename, clean_lines, linenum, error)

Source from the content-addressed store, hash-verified

2122
2123
2124def CheckPosixThreading(filename, clean_lines, linenum, error):
2125 """Checks for calls to thread-unsafe functions.
2126
2127 Much code has been originally written without consideration of
2128 multi-threading. Also, engineers are relying on their old experience;
2129 they have learned posix before threading extensions were added. These
2130 tests guide the engineers to use thread-safe functions (when using
2131 posix directly).
2132
2133 Args:
2134 filename: The name of the current file.
2135 clean_lines: A CleansedLines instance containing the file.
2136 linenum: The number of the line to check.
2137 error: The function to call with any errors found.
2138 """
2139 line = clean_lines.elided[linenum]
2140 for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST:
2141 # Additional pattern matching check to confirm that this is the
2142 # function we are looking for
2143 if Search(pattern, line):
2144 error(filename, linenum, 'runtime/threadsafe_fn', 2,
2145 'Consider using ' + multithread_safe_func +
2146 '...) instead of ' + single_thread_func +
2147 '...) for improved thread safety.')
2148
2149
2150def CheckVlogArguments(filename, clean_lines, linenum, error):

Callers 1

ProcessLineFunction · 0.85

Calls 2

SearchFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected