Skip to content

Conversation

Atry
Copy link
Contributor

@Atry Atry commented May 25, 2016

This change may enhance performance if close operation take a long time

Atry added 2 commits May 25, 2016 12:25
This change may enhance performance if close operation take a long time
@jsuereth
Copy link
Owner

Before merging this, can you take a look at #47 - Specifically how to handle the case where an exception is thrown in one of the threads and then what should happen when another thread tries to access the resource.

}
}
if (newValue.isEmpty) {
implicitly[Resource[A]].close(r)
Copy link
Owner

Choose a reason for hiding this comment

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

This could be called multiple times, which I think is unsafe, concurrency-wise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it will never be called multiple times for the same r instance

@jsuereth
Copy link
Owner

jsuereth commented Jun 1, 2016

The more I think about it the more I'm hesitant on multi-threading features without more multi-threaded controls, especially if we don't know whether theunderlying resource is "concurrency safe"

Copy link
Collaborator

@cchantep cchantep left a comment

Choose a reason for hiding this comment

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

Considering the complexity and not obvious improvement, I would close this for now.

if (oldReferenceCount == 1) {
implicitly[Resource[A]].close(sc)
sharedReference = None
val newValue = if (oldReferenceCount == 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shadow newValue

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants