MCPcopy Create free account
hub / github.com/BVLC/caffe / CheckPosixThreading

Function CheckPosixThreading

scripts/cpp_lint.py:1685–1709  ·  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

1683
1684
1685def CheckPosixThreading(filename, clean_lines, linenum, error):
1686 """Checks for calls to thread-unsafe functions.
1687
1688 Much code has been originally written without consideration of
1689 multi-threading. Also, engineers are relying on their old experience;
1690 they have learned posix before threading extensions were added. These
1691 tests guide the engineers to use thread-safe functions (when using
1692 posix directly).
1693
1694 Args:
1695 filename: The name of the current file.
1696 clean_lines: A CleansedLines instance containing the file.
1697 linenum: The number of the line to check.
1698 error: The function to call with any errors found.
1699 """
1700 line = clean_lines.elided[linenum]
1701 for single_thread_function, multithread_safe_function in threading_list:
1702 ix = line.find(single_thread_function)
1703 # Comparisons made explicit for clarity -- pylint: disable=g-explicit-bool-comparison
1704 if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and
1705 line[ix - 1] not in ('_', '.', '>'))):
1706 error(filename, linenum, 'runtime/threadsafe_fn', 2,
1707 'Consider using ' + multithread_safe_function +
1708 '...) instead of ' + single_thread_function +
1709 '...) for improved thread safety.')
1710
1711
1712def CheckVlogArguments(filename, clean_lines, linenum, error):

Callers 1

ProcessLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected