• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

thread safe variable

Explorer ,
Jul 20, 2020 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
SDK , Windows

Views

147

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
community guidelines
LEGEND ,
Jul 20, 2020 Jul 20, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines