WSEnableLinkLock (C Function)

void WSEnableLinkLock ( WSLINK l )

turns on thread safety for the WSTP connection specified by l.


  • By default, WSTP link objects are not thread safe with respect to calling WSTP API functions for the same link from multiple threads simultaneously. After calling WSEnableLinkLock() for a link object, that link can then be used simultaneously from multiple threads of execution.
  • Thread safety introduces a small performance penalty in order to maintain the integrity of the internal data stream for a given link object. All threaded programs that use shared resources incur this penalty when protecting access to a shared resource.
  • Thread safety can be disabled for l by calling WSDisableLinkLock().
  • WSEnableLinkLock() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

int main(int argc, char **argv)
    WSENV env;
    WSLINK link;
    int error;

    env = WSInitialize((WSEnvironmentParameter)0);
    if(env == (WSENV)0)
    { /* Unable to create WSTP environment object */ }

    link = WSOpenArgcArgv(env, argc, argv, &error);
    if(link == (WSLINK)0 || error != WSEOK)
    { /* Unable to create link object */ }



    /* ... */


    return 0;