OpenersNotesSection(Spacer1)Details

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 (NonWLLink[WSDisableLinkLock(), paclet:ref/c/WSDisableLinkLock]).

WSEnableLinkLock() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */ }

	WSActivate(link);

	WSEnableLinkLock(link);

	/* ... */

	WSClose(link);
	WSDeinitialize(env);

	return 0;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSDisableLinkLock(), paclet:ref/c/WSDisableLinkLock])  ▪  (NonWLLink[WSSetThreadSafeLinksParameter(), paclet:ref/c/WSSetThreadSafeLinksParameter])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}})}})