-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support duplicate context duplication.
Motivation: Duplicating a duplicated context is supported but the duplication semantic is not defined. Changes: This update the duplicated context duplication by doing a copy of each local in the duplicated duplicate. This introduce a duplicator for each local that is responsible for copying the object when it is not null.
- Loading branch information
Showing
10 changed files
with
108 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,27 @@ | |
|
||
import io.vertx.core.spi.context.storage.ContextLocal; | ||
|
||
import java.util.function.Function; | ||
|
||
/** | ||
* @author <a href="mailto:[email protected]">Julien Viet</a> | ||
*/ | ||
public class ContextLocalImpl<T> implements ContextLocal<T> { | ||
|
||
public static <T> ContextLocal<T> create(Class<T> type, Function<T, T> duplicator) { | ||
synchronized (LocalSeq.class) { | ||
int idx = LocalSeq.locals.size(); | ||
ContextLocal<T> local = new ContextLocalImpl<>(idx, duplicator); | ||
LocalSeq.locals.add(local); | ||
return local; | ||
} | ||
} | ||
|
||
final int index; | ||
final Function<T, T> duplicator; | ||
|
||
public ContextLocalImpl(int index) { | ||
public ContextLocalImpl(int index, Function<T, T> duplicator) { | ||
this.index = index; | ||
} | ||
|
||
public ContextLocalImpl() { | ||
this.index = LocalSeq.next(); | ||
this.duplicator = duplicator; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters