Highlighted

thread safe variable

Explorer ,
Jul 20, 2020

Copy link to clipboard

Copied

I am running few functions using 

LrFunctionContext.postAsyncTaskWithContext

All of them access and modify a variable. How can I make sure this variable is async safe. 

Topics

Mac, SDK, Sync, Windows

Views

26

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

thread safe variable

Explorer ,
Jul 20, 2020

Copy link to clipboard

Copied

I am running few functions using 

LrFunctionContext.postAsyncTaskWithContext

All of them access and modify a variable. How can I make sure this variable is async safe. 

Topics

Mac, SDK, Sync, Windows

Views

27

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 20, 2020 0
Most Valuable Participant ,
Jul 20, 2020

Copy link to clipboard

Copied

LR tasks (including the main task) are non-preemptive -- only one task runs at a time, and tasks switch only when a yielding API call is invoked.  Which calls are yielding aren't well documented, but generally any call that must be executed within an async task could potentially yield.

 

So you can be confident that in between a task's calls to yielding API calls, another task won't run behind the scenes.

 

See this post for more information about API calls that yield:

https://feedback.photoshop.com/photoshop_family/topics/lightroom-sdk-many-methods-yield-preventing-r...

 

It's actually quite tricky to program a plugin correctly, especially if you use floating dialogs or background tasks that run while the user is interacting with the application.

 

[Use the blue reply button under the first post to ensure replies sort properly.]

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0