[google/guice] 6b4bbe: Add a default value and make it true for dagger & ...

5 views
Skip to first unread message

GitHub

unread,
Apr 20, 2015, 8:51:15 PM4/20/15
to google-g...@googlegroups.com
Branch: refs/heads/moe_writing_branch_from_156c8cc762fab971efb727c7ab107fa243be2fc9
Home: https://github.com/google/guice
Commit: 6b4bbe9123c0ba6b362978cda6f6714c83f154c4
https://github.com/google/guice/commit/6b4bbe9123c0ba6b362978cda6f6714c83f154c4
Author: sameb <sa...@google.com>
Date: 2015-04-20 (Mon, 20 Apr 2015)

Changed paths:
M extensions/multibindings/src/com/google/inject/multibindings/MapKey.java

Log Message:
-----------
Add a default value and make it true for dagger & guice MapKey.
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=89998087


Commit: 6986d188358d2aa60ba2cce93c86438c35c5e0eb
https://github.com/google/guice/commit/6986d188358d2aa60ba2cce93c86438c35c5e0eb
Author: timofeyb <timo...@google.com>
Date: 2015-04-20 (Mon, 20 Apr 2015)

Changed paths:
M core/src/com/google/inject/internal/BindingProcessor.java
M core/src/com/google/inject/internal/BoundProviderFactory.java
M core/src/com/google/inject/internal/ConstructionContext.java
M core/src/com/google/inject/internal/ConstructorBindingImpl.java
M core/src/com/google/inject/internal/ConstructorInjector.java
A core/src/com/google/inject/internal/CycleDetectingLock.java
M core/src/com/google/inject/internal/DelegatingInvocationHandler.java
M core/src/com/google/inject/internal/Errors.java
M core/src/com/google/inject/internal/InheritingState.java
M core/src/com/google/inject/internal/InjectorImpl.java
M core/src/com/google/inject/internal/InternalContext.java
M core/src/com/google/inject/internal/InternalFactoryToInitializableAdapter.java
M core/src/com/google/inject/internal/ProvidedByInternalFactory.java
M core/src/com/google/inject/internal/ProviderInternalFactory.java
M core/src/com/google/inject/internal/Scoping.java
M core/src/com/google/inject/internal/SingletonScope.java
M core/src/com/google/inject/internal/State.java
M core/test/com/google/inject/ScopesTest.java
A core/test/com/google/inject/internal/CycleDetectingLockTest.java

Log Message:
-----------
Implement more granular locks for a Singleton scope in Guice.

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


Compare: https://github.com/google/guice/compare/6b4bbe9123c0^...6986d188358d
Reply all
Reply to author
Forward
0 new messages