Skip to content

Use FlsAlloc/FlsFree/FlsGetValue/FlsSetValue instead of TlsAlloc/TlsFree/TlsGetValue/TlsSetValue to implment TLS value cleanup when thread has been terminated on Windows Vista and above#15812

Merged
alalek merged 5 commits intoopencv:3.4from
yuriyluxriot:fls_replaces_tls
Nov 1, 2019

Conversation

@yuriyluxriot
Copy link
Copy Markdown
Contributor

@yuriyluxriot yuriyluxriot commented Oct 30, 2019

System information (version)
  • OpenCV => 4.1.2-dev
  • Operating System / Platform => Windows 7 64-bit
  • Compiler => Visual Studio 2015
Detailed description

Use FlsAlloc/FlsFree/FlsGetValue/FlsSetValue instead of TlsAlloc/TlsFree/TlsGetValue/TlsSetValue to implment TLS operations and cleanup of value when thread has been terminated on Windows Vista and above.
Fls-functions operates on fiber local storage (FLS) and FlsAlloc allows to specify application-defined callback function. If the FLS slot is in use, then callback is called on fiber deletion, thread exit, and when an FLS index is freed. For more information see https://docs.microsoft.com/en-us/windows/win32/api/fibersapi/nf-fibersapi-flsalloc

In orer to use Fls-functions need to define _WIN32_WINNT to 0x0600 or above.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is about DllMain() THREAD_DETACH calls?

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right! Static builds can't work through DllMain notifications.

Please move this patch into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

@yuriyluxriot yuriyluxriot changed the base branch from master to 3.4 November 1, 2019 13:37
@alalek
Copy link
Copy Markdown
Member

alalek commented Nov 1, 2019

Do not merge.
I will rebase your commits.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants