MLSetThreadSafeLinksParameter (C Function)

MLSetThreadSafeLinksParameter has been replaced by WSSetThreadSafeLinksParameter.

long MLSetThreadSafeLinksParameter(MLEnvironmentParameter p)

enables thread safety for all links created by the MathLink environment object initialized with p.

Details

  • 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.

Examples

Basic Examples  (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;
}