MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / CheckPosixThreading

Function CheckPosixThreading

src/tests/coding/cpplint.py:2610–2633  ·  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

2608
2609
2610def CheckPosixThreading(filename, clean_lines, linenum, error):
2611 """Checks for calls to thread-unsafe functions.
2612
2613 Much code has been originally written without consideration of
2614 multi-threading. Also, engineers are relying on their old experience;
2615 they have learned posix before threading extensions were added. These
2616 tests guide the engineers to use thread-safe functions (when using
2617 posix directly).
2618
2619 Args:
2620 filename: The name of the current file.
2621 clean_lines: A CleansedLines instance containing the file.
2622 linenum: The number of the line to check.
2623 error: The function to call with any errors found.
2624 """
2625 line = clean_lines.elided[linenum]
2626 for single_thread_func, multithread_safe_func, pattern in _THREADING_LIST:
2627 # Additional pattern matching check to confirm that this is the
2628 # function we are looking for
2629 if Search(pattern, line):
2630 error(filename, linenum, 'runtime/threadsafe_fn', 2,
2631 'Consider using ' + multithread_safe_func +
2632 '...) instead of ' + single_thread_func +
2633 '...) for improved thread safety.')
2634
2635
2636def CheckVlogArguments(filename, clean_lines, linenum, error):

Callers 1

ProcessLineFunction · 0.85

Calls 1

SearchFunction · 0.85

Tested by

no test coverage detected