-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support duplicated context duplication #5215
base: master
Are you sure you want to change the base?
Conversation
@franz1981 @cescoffier please have a look |
This can be related (and better used at) quarkusio/quarkus#40725 can you checkout my branch there and show how the changes there will translate with the new API, bud? I'm travelling, but I would like, before it got merged, to make sure the semantic and behaviours won't change too much and instead we save some code by leveraging this new feature (which is super cool!) |
for now this is a tentative PR, we can discuss next week @franz1981 I think |
Yep, let's sync once I'm back, thanks @vietj 🙏 |
|
||
final int index; | ||
final Class<T> type; | ||
final Function<T, ? extends T> duplicator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueDuplicator
@@ -164,7 +164,28 @@ public boolean isWorkerContext() { | |||
|
|||
@Override | |||
public ContextInternal duplicate() { | |||
return new DuplicatedContext(delegate, locals.length == 0 ? VertxImpl.EMPTY_CONTEXT_LOCALS : new Object[locals.length]); | |||
Object[] localsDuplicate = locals.length == 0 ? VertxImpl.EMPTY_CONTEXT_LOCALS : locals.clone(); | |||
ContextLocal<?>[] contextLocals = ((VertxImpl) delegate.owner()).contextLocals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the CHM is forcibly at index 0 why we cannot just treat it already separately without having a specific interface to perform the duplication?
This will make the tight loop here to be replaced by an optimized Arrays's batch copy (using Arrays.copyOf-like methods) + a "special" reset of the 0 key - which is the CHM one
… actual locals is not defined. 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.
ace4b39
to
dc2f1fb
Compare
Duplicating a duplicated context is supported but the semantic of the actual locals is not defined.
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.