bloomberg / bloomberg/ntf-core

Callback factories

Open
#23 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
99
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Why would I use a callback factory when setting up an async call? I can do this:
```
auto callback = socket_->createReceiveCallback([this](auto receiver, auto blob, auto event) {
received_identity(receiver, blob, event);
});
auto error = socket_->receive(r_opts, callback);
```
This works fine. But I can also do this:
```
auto error = socket_->receive(r_opts, [this](auto receiver, auto blob, auto event) {
received_identity(receiver, blob, event);
});
```
Whether I use the callback from the factory or pass a lambda directly makes no apparent difference. Why would I use one over the other?

Contributor guide

Open the contributing guide

Research direction

Start by comparing the socket_->createReceiveCallback factory with the socket_->receive overload that accepts a lambda, including their API documentation and behavior. Document the concrete differences, if any, and explain when a caller should use each form.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.