bloomberg / bloomberg/ntf-core
Callback factories
- 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
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