Trusted Software Excellence across Desktop and Embedded
Take a glance at the areas of expertise where KDAB excels ranging from swift troubleshooting, ongoing consulting and training to multi-year, large-scale software development projects.
Find out why customers from innovative industries rely on our extensive expertise, including Medical, Biotech, Science, Renewable Energy, Transportation, Mobility, Aviation, Automation, Electronics, Agriculture and Defense.
High-quality Embedded Engineering across the Stack
To successfully develop an embedded device that meets your expectations regarding quality, budget and time to market, all parts of the project need to fit perfectly together.
Learn more about KDAB's expertise in embedded software development.
Where the capabilities of modern mobile devices or web browsers fall short, KDAB engineers help you expertly architect and build high-functioning desktop and workstation applications.
Extensible, Safety-compliant Software for the Medical Sector
Create intelligent, patient-focused medical software and devices and stay ahead with technology that adapts to your needs.
KDAB offers you expertise in developing a broad spectrum of clinical and home-healthcare devices, including but not limited to, internal imaging systems, robotic surgery devices, ventilators and non-invasive monitoring systems.
Building digital dashboards and cockpits with fluid animations and gesture-controlled touchscreens is a big challenge.
In over two decades of developing intricate UI solutions for cars, trucks, tractors, scooters, ships, airplanes and more, the KDAB team has gained market leading expertise in this realm.
Build on Advanced Expertise when creating Modern UIs
KDAB assists you in the creation of user-friendly interfaces designed specifically for industrial process control, manufacturing, and fabrication.
Our specialties encompass the custom design and development of HMIs, enabling product accessibility from embedded systems, remote desktops, and mobile devices on the move.
Legacy software is a growing but often ignored problem across all industries. KDAB helps you elevate your aging code base to meet the dynamic needs of the future.
Whether you want to migrate from an old to a modern GUI toolkit, update to a more recent version, or modernize your code base, you can rely on over 25 years of modernization experience.
KDAB offers a wide range of services to address your software needs including consulting, development, workshops and training tailored to your requirements.
Our expertise spans cross-platform desktop, embedded and 3D application development, using the proven technologies for the job.
When working with KDAB, the first-ever Qt consultancy, you benefit from a deep understanding of Qt internals, that allows us to provide effective solutions, irrespective of the depth or scale of your Qt project.
Qt Services include developing applications, building runtimes, mixing native and web technologies, solving performance issues, and porting problems.
KDAB helps create commercial, scientific or industrial desktop applications from scratch, or update its code or framework to benefit from modern features.
Discover clean, efficient solutions that precisely meet your requirements.
Boost your team's programming skills with in-depth, constantly updated, hands-on training courses delivered by active software engineers who love to teach and share their knowledge.
Our courses cover Modern C++, Qt/QML, Rust, 3D programming, Debugging, Profiling and more.
The collective expertise of KDAB's engineering team is at your disposal to help you choose the software stack for your project or master domain-specific challenges.
Our particular focus is on software technologies you use for cross-platform applications or for embedded devices.
Since 1999, KDAB has been the largest independent Qt consultancy worldwide and today is a Qt Platinum partner. Our experts can help you with any aspect of software development with Qt and QML.
KDAB specializes in Modern C++ development, with a focus on desktop applications, GUI, embedded software, and operating systems.
Our experts are industry-recognized contributors and trainers, leveraging C++'s power and relevance across these domains to deliver high-quality software solutions.
KDAB can guide you incorporating Rust into your project, from as overlapping element to your existing C++ codebase to a complete replacement of your legacy code.
Unique Expertise for Desktop and Embedded Platforms
Whether you are using Linux, Windows, MacOS, Android, iOS or real-time OS, KDAB helps you create performance optimized applications on your preferred platform.
If you are planning to create projects with Slint, a lightweight alternative to standard GUI frameworks especially on low-end hardware, you can rely on the expertise of KDAB being one of the earliest adopters and official service partner of Slint.
KDAB has deep expertise in embedded systems, which coupled with Flutter proficiency, allows us to provide comprehensive support throughout the software development lifecycle.
Our engineers are constantly contributing to the Flutter ecosystem, for example by developing flutter-pi, one of the most used embedders.
KDAB invests significant time in exploring new software technologies to maintain its position as software authority. Benefit from this research and incorporate it eventually into your own project.
Start here to browse infos on the KDAB website(s) and take advantage of useful developer resources like blogs, publications and videos about Qt, C++, Rust, 3D technologies like OpenGL and Vulkan, the KDAB developer tools and more.
The KDAB Youtube channel has become a go-to source for developers looking for high-quality tutorial and information material around software development with Qt/QML, C++, Rust and other technologies.
Click to navigate the all KDAB videos directly on this website.
In over 25 years KDAB has served hundreds of customers from various industries, many of them having become long-term customers who value our unique expertise and dedication.
Learn more about KDAB as a company, understand why we are considered a trusted partner by many and explore project examples in which we have proven to be the right supplier.
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications.
Read more about the history, the values, the team and the founder of the company.
When working with KDAB you can expect quality software and the desired business outcomes thanks to decades of experience gathered in hundreds of projects of different sizes in various industries.
Have a look at selected examples where KDAB has helped customers to succeed with their projects.
KDAB is committed to developing high-quality and high-performance software, and helping other developers deliver to the same high standards.
We create software with pride to improve your engineering and your business, making your products more resilient and maintainable with better performance.
KDAB has been the first certified Qt consulting and software development company in the world, and continues to deliver quality processes that meet or exceed the highest expectations.
In KDAB we value practical software development experience and skills higher than academic degrees. We strive to ensure equal treatment of all our employees regardless of age, ethnicity, gender, sexual orientation, nationality.
Interested? Read more about working at KDAB and how to apply for a job in software engineering or business administration.
The time has come, fellow devs. We are on our way to uncover the newest concept of C++ language - Coroutines. They are already used by several programming languages, like
C# async tasks and yield iterables, forming LINQ base;
JS with awaitables, replacing the old way of making consecutive calls, that was hard to understand did a lot of code identation for cases that required a lot of async execution;
Python with synchronous generator
etc.
They were introduced in the recent C++20 standard. However, instead of handy classes such as Task<> and std::generator<> we received a complex and low-level toolkit to make our own promises and futures. Only C++23 gave us our first usable coroutine type (std::generator<>). It seems like the C++ committee followed the quote: "give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime".
Today we will discuss what is needed to understand coroutines, and in the later chapters we will make our own little coroutine.
We need a lot more to understand them, though. To start off, let's discuss what the first part of the definition above means. The part "to be suspended and resumed" feels like magic to a regular programmer, who has worked with regular functions their whole career, like me.
What does "suspend" mean?
It sounds a lot like system("pause"), or something like getchar(), that suspends execution, doesn't it? However, although it may sound like 'suspend the execution' stops the program, that's not even remotely close to what it means. In this context it means coroutines may switch between the execution of function bodies in real time, without program suspension.
A calls B, but B resumes A... Still magic, nothing has changed.
Another Way
Let's look at it another way. If the definition and implementation are arcane, we need to take ourselves to a journey of creativity. Behind every invention there is someone who wanted to make something work. What could that be exactly in this context? The name coroutine implies that some routine is running in parallel with another. However, there is a catch: there is no multithreading involved.
How can we achieve parallel execution with a single thread? Let's take a look at video editing to illustrate how this works.
You could break several videos into chunks and splice these chunks together in a sequence that fits what you want to say. Or, looked at from another angle, you could program those videos to yield the timeline to other videos at the right time, resulting in one seamless timeline. What we see is only one timeline and several videos, resembling a single thread and tasks, that want to run on that thread.
One way to interpret that in the programming world would be a central function, that calls other functions in sequence. But the other approach is more interesting. You see, you can just stop one video, let the other video play for some time and continue the first video from the place where it had stopped previously. How do we achieve similar behavior in code? How do you suspend the code and resume after the suspend?
Example
Let's assume we have a program, which should work like this:
voidf(){int a =0;++a;...suspend/yield magic()...print(a);}
The idea that comes to mind is to just store a variable, that says where to execute the code. As my colleague once asked me, Is 'switch on state' a way to make a coroutine? It goes like this:
Except it is not yet complete. If there were any other variables inside or arguments, you would not get what you desire. Let's make a simple example:
voidFunction(ExecutionState* state){int a =0;switch(*state){case0: a++;*state =1;return;case1:printf("%d", a);return;}}
What would the function print out if I was to call it twice? Well, the obvious answer would be 0. It will lose its internal state if called upon the second time and re-initialize the variable a with 0.
What do we know so far?
We have defined two parts that make a coroutine stand out:
The coroutine may yield, stopping its execution and letting other coroutines take the control.
The coroutine saves all the states of execution, including modified variables and input arguments.
If we look at the regular function, all its state is cleared when the execution goes out of scope. That is due to the nature of C functions, which save all the variables on a stack or in registers. What if it wasn't constrained? Then we could use a heap or a static storage to save the state. The state would then retain its value.
Let's make the example from above work:
structExecutionState{int state;int a;};voidFunction(ExecutionState* state){//assume that state is initialized with zeroesswitch(*state){case0: state->a++; state->state =1;return;case1:printf("%d", state->a);return;}}
Now that we placed the a variable in state we made the value retain its value across the calls.
The first one is harder, though, since the regular execution of functions only returns control to the callee.
Furthermore, we didn't talk about corner cases of suspension of execution or exception handling.
A lot of tasks to solve indeed. We will tackle those in the next part of the series.
Conclusion
We have just scratched the surface of a big iceberg which is coroutines. For now, we have solved the persistent state problem, and we are on our way to define basic principles of a coroutine.
There is a lot more to unravel. We will explore what stackless and stackful coroutines are, symmetric and asymmetric ones and, of course, asynchronous usage of coroutines. For the time being, we have a basic understanding of the idea of coroutines and we are ready to make our first assumptions on how they work.
Thank you for reading, and see you in the next post.
Sincerely,
Ilya "Agrael" Doroshenko
About KDAB
Trusted software excellence across embedded and desktop platforms
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
I really enjoyed the short intro to coroutines. I wanted to make a suggestion on the last code example. Where the code reads switch(*state){, I think it would make more sense to have switch(state->state){ instead.
I'm looking forward to reading the next post on coroutines!
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
1 Comment
18 - Nov - 2023
Abel Sen
Hi Ilya,
I really enjoyed the short intro to coroutines. I wanted to make a suggestion on the last code example. Where the code reads
switch(*state){
, I think it would make more sense to haveswitch(state->state){
instead.I'm looking forward to reading the next post on coroutines!