CodeTools - Maple Programming Help

Home : Support : Online Help : Programming : CodeTools : CodeTools/ThreadSafetyCheck

CodeTools

 analyze a procedure or module for potential thread safety issues

Parameters

 p - procedure or module

Description

 • The ThreadSafetyCheck command analyzes the given procedure or module and warns about specific thread-safety issues.
 • Currently warnings are limited to the use of global variables and the use of lexically scoped local variables that are seen in assignment statements.
 • The return value consists of a sequence of two integers counting the number of procedures flagged with thread-safety issues, followed by the total number of procedures analyzed.

Examples

 > $\mathrm{with}\left(\mathrm{CodeTools}\right):$
 > p := proc(a) global x; x*a; end;
 ${p}{≔}{\mathbf{proc}}\left({a}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{global}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{x}{*}{a}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $\left[\mathrm{ThreadSafetyCheck}\left(p\right)\right]$
 Warning, proc p has declared globals [x]
 $\left[{1}{,}{1}\right]$ (2)
 > m := module() export p1, p2; local a; p1 := proc(n) a := n; end; p2 := proc(n) a^n; end; end module;
 ${m}{≔}{\mathbf{module}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{a}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{export}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{p1}}{,}{\mathrm{p2}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end module}}$ (3)
 > $\left[\mathrm{ThreadSafetyCheck}\left(m\right)\right]$
 Warning, proc p1 uses lexical a Warning, proc p2 uses lexical a
 $\left[{2}{,}{2}\right]$ (4)

Compatibility

 • The CodeTools[ThreadSafetyCheck] command was introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.