MLSetThreadSafeLinksParameter (C 函数)
MLSetThreadSafeLinksParameter 已经被 WSSetThreadSafeLinksParameter 所取代.
long MLSetThreadSafeLinksParameter(MLEnvironmentParameter p)
enables thread safety for all links created by the MathLink environment object initialized with p.
更多信息
- By default, MathLink link objects are not thread-safe. To enable thread-safety for all link objects produced by a MathLink environment object by default, set the thread-safety parameter with MLSetThreadSafeLinksParameter().
- Thread-safety for link objects means that multiple threads can call MathLink API functions on the same link object simultaneously.
- p must have been created using the MLNewParameters() MathLink API function.
- MLSetThreadSafeLinksParameter() returns error codes using the standard error values as returned by MLError().
- MLSetThreadSafeLinksParameter() is declared in the MathLink header file mathlink.h.
范例
基本范例 (1)
#include "mathlink.h"
int main()
{
MLEnvironmentParameter ep;
MLENV env;
long apiResult;
ep = MLNewParameters(MLREVISION, MLAPIREVISION);
if(ep == (MLEnvironmentParameter)0)
{ /* Unable to create the MLEnvironmentParameter object. */ }
apiResult = MLSetThreadSafeLinksParameter(ep);
if(apiResult != MLEOK)
{ /* Failed to set thread-safe links parameter */ }
env = MLInitialize(ep);
if(env == (MLENV)0)
{ /* Failed to initialize MathLInk environment object */ }
MLReleaseParameters(ep);
/* ... */
MLDeinitialize(env);
return 0;
}