Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge internal changes #915

Merged

Conversation

sameb
Copy link
Member

@sameb sameb commented Apr 21, 2015

Notably, this changes the singleton scope to get rid of the injector-wide lock.

@sameb
Copy link
Member Author

sameb commented Apr 21, 2015

FYI the dagger interop maven stuff is breaking due to the dagger 2.0 release. @cgruber is going to fix.

sameb and others added 3 commits April 21, 2015 09:37
Now when you can create two independent singletons using
the same injector in different threads.
This make it easy to create scopes creating singletons using
thread pools with all the concurrency being done by Guice.
As a nice side effect Singleton scope is no longer treated
specially in Guice codebase.

The obvious problem to solve is potential deadlocks:
A requires B, B requires C, C requires A where all are
singletons and all are created simultaneously.
It's impossible to detect this deadlock using information
within one thread, so we have to have a shared storage.

An idea is to have a map of creators' locks and a map
of which threads are waiting for other singletons to be created.
Using this information circular dependencies are trivially
discovered within O(N) where N is a number of concurrent threads.

Important to not that no other deadlock scenarios within
Guice code is introduced as Guice does not expose any
other scopes that can span several threads.

Now it would be possible for
client code to deadlock on itself with two lazy singletons
calling each other's providers during creation.
This is deemed as a non-issue as it is up to the client
to write a thread-safe code.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=91610630
…date api jar for the ant build)

-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=91679331
@sameb sameb force-pushed the moe_writing_branch_from_156c8cc762fab971efb727c7ab107fa243be2fc9 branch from 6986d18 to 3809a81 Compare April 21, 2015 13:44
@sameb
Copy link
Member Author

sameb commented Apr 21, 2015

OK this is all set now.

@cgdecker
Copy link
Member

LGTM

sameb added a commit that referenced this pull request Apr 21, 2015
…2fab971efb727c7ab107fa243be2fc9

Merge internal changes
@sameb sameb merged commit e3f5566 into master Apr 21, 2015
@sameb sameb deleted the moe_writing_branch_from_156c8cc762fab971efb727c7ab107fa243be2fc9 branch April 21, 2015 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants