Skip to content

Details

Description

Damir will give a practical example of using coroutines in socket-based communication.

We will redesign the receiver component, common for both endpoints, for handling the data exchange. We will start with a naïve approach – trying directly to replace existing code with a coroutine and explaining why this is an antipattern. Then we will redesign the receiver to be coroutines “friendly” and how we can reimplement the Server and Client components – to handle multiple connections within a single thread, instead of having one receiver thread per connection.

We will also explore how we can employ custom allocators to override the coroutine default allocation strategy – allocation on the heap. I’ll describe the implementation, starting with the fixed-size stack allocator – with internal memory storage on the stack, and how to build the pool of fixed-size allocators of different sizes on top of it. We will wrap this implementation into std::pmr::memory_resource interface to have a polymorphic, type-erased allocator that can be used along with std::pmr containers. We will use it to override the coroutine default allocation strategy, allocating memory primarily on the stack, with a fallback strategy – allocating on the heap, only when the capacity of the internal stack storage is exhausted.

About the Presenter

Damir Ljubić is a Principal SW Engineer at e.solutions GmbH in Ingolstadt, Germany. As a member of the connected-media team, he's responsible for the seamless integration of smartphone streaming technologies into the native Infotainment system. Previously worked at RT-RK DOO Novi Sad, Serbia, on various projects – mostly on developing the DTV (Digital Television) software. His upcoming book "Infotainment Development on Android", due to release later this year, is intended to be a pragmatic guide that helps even experienced software developers gain insights into various areas of embedded development.

Related topics

C & C++
Computer Programming
Software Development
Software Engineering

Sponsors

Here

Here

Many thanks to Here for sponsoring our event of September 21, 2017

EZE Software Group

EZE Software Group

Many thanks to EZE Software Group for providing us with a place to meet.

Spot Trading, LLC

Spot Trading, LLC

Many thanks to Spot Trading, LLC, for providing us with a place to meet.

JetBrains

JetBrains

Many thanks for giving us free coupons for their software products

You may also like