Skip to content

Feat[mqb]: store AppConfig value, not a pointer to config#1329

Open
678098 wants to merge 2 commits intobloomberg:mainfrom
678098:260423_store_config_copy
Open

Feat[mqb]: store AppConfig value, not a pointer to config#1329
678098 wants to merge 2 commits intobloomberg:mainfrom
678098:260423_store_config_copy

Conversation

@678098
Copy link
Copy Markdown
Collaborator

@678098 678098 commented Apr 23, 2026

mqbcfg::BrokerConfig only stores a pointer to an external configuration object. Due to this, the configuration object must be kept alive in runtime, or the pointer becomes invalid.
It is possible to make a copy of a provided configuration and remove the restriction of keeping configuration object alive.

@678098 678098 requested a review from a team as a code owner April 23, 2026 18:48
@678098 678098 changed the title Feat[mqb]: store AppConfig value, not a pointer to config Feat[mqb]: store AppConfig value, not a pointer to config Apr 23, 2026
@678098 678098 force-pushed the 260423_store_config_copy branch from 5e9e1f7 to 1291bfc Compare April 23, 2026 20:06
@678098 678098 requested a review from hallfox April 24, 2026 18:41
Comment on lines +39 to +45
static bsls::ObjectBuffer<mqbcfg::AppConfig> appConfig;
BSLMT_ONCE_DO
{
new (static_cast<void*>(appConfig.buffer()))
mqbcfg::AppConfig(bmqu::SingletonAllocator::allocator());
}
return &appConfig.object();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we want to have the actual objects managed by the singleton allocator? e.g.

static mqbcfg::AppConfig* appConfig_p;
BSLMT_ONCE_DO {
  bslma::Allocator* alloc = bmqu::SingletonAllocator::allocator();
  appConfig_p = bslma::AllocatorUtil::newObject<mqbcfg::AppConfig>(alloc);
}
return *appConfig_p;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@678098 678098 force-pushed the 260423_store_config_copy branch from fd48040 to c92298a Compare April 24, 2026 21:40
Signed-off-by: Evgeny Malygin <emalygin@bloomberg.net>
@678098 678098 force-pushed the 260423_store_config_copy branch from c92298a to 1e01e85 Compare April 24, 2026 21:41
@678098 678098 requested a review from hallfox April 24, 2026 21:42
Signed-off-by: Evgenii Malygin <2518859+678098@users.noreply.github.com>
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.

2 participants