Skip to content

[QST] Some confusion for GpuSemaphore.releaseIfNecessary() #5385

Answered by revans2
JustPlay asked this question in General
Discussion options

You must be logged in to vote

That code is checking to see if the current task owns the semaphore and releases it only if it does.

It is a little confusing because it uses a MutableInt as a reference count. Originally it was intended that we would reference count how many times we asked to grab the semaphore and only release it when we hit the same number, but that proved to be impossible, so now the value of the reference count is always 1 or 0. It goes to 1 when a task grabs the semaphore and goes to 0 when it releases the semaphore. Al other times the code looks to see if the task already has the semaphore and lets it through, or the release becomes a noop.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sameerz
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #858 on April 28, 2022 23:11.