OpenersNotesSection(Spacer1)Details

By default, WSTP link objects are not thread-safe. To enable thread-safety for all link objects produced by a WSTP environment object by default, set the thread-safety parameter with WSSetThreadSafeLinksParameter().

Thread-safety for link objects means that multiple threads can call WSTP API functions on the same link object simultaneously.

p must have been created using the (NonWLLink[WSNewParameters(), paclet:ref/c/WSNewParameters]) WSTP API function.

WSSetThreadSafeLinksParameter() returns error codes using the standard error values as returned by (NonWLLink[WSError(), paclet:ref/c/WSError]).

WSSetThreadSafeLinksParameter() 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()
{
	WSEnvironmentParameter ep;
	WSENV env;
	long apiResult;
	
	ep = WSNewParameters(WSREVISION, WSAPIREVISION);
	if(ep == (WSEnvironmentParameter)0)
	{ /* Unable to create the WSEnvironmentParameter object. */ }

	apiResult = WSSetThreadSafeLinksParameter(ep);
	if(apiResult != WSEOK)
	{ /* Failed to set thread-safe links parameter */ }

	env = WSInitialize(ep);
	if(env == (WSENV)0)
	{ /* Failed to initialize WSTP environment object */ }

	WSReleaseParameters(ep);

	/* ... */

	WSDeinitialize(env);

	return 0;
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSNewParameters(), paclet:ref/c/WSNewParameters])  ▪  (NonWLLink[WSReleaseParameters(), paclet:ref/c/WSReleaseParameters])  ▪  (NonWLLink[WSInitialize(), paclet:ref/c/WSInitialize])}})}})

({{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])}})}})