-
Notifications
You must be signed in to change notification settings - Fork 8.3k
zbus: Introduce Async Listener #98142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nashif
merged 6 commits into
zephyrproject-rtos:main
from
rodrigopex:zbus_async_listener
Nov 21, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fbfa8cf
zbus: introduce async listeners
rodrigopex f284a58
tests: zbus: add async listeners tests
rodrigopex 5a16e00
tests: zbus: filter out tests that aren't SMP aware
rodrigopex 31426d8
samples: zbus: async listeners sample
rodrigopex 3f78f19
samples: zbus: add async linstener to the hello world sample
rodrigopex 3ae3aef
doc: zbus: async listeners
rodrigopex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| cmake_minimum_required(VERSION 3.20.0) | ||
|
|
||
| find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
| project(async_listener) | ||
|
|
||
| FILE(GLOB app_sources src/*.c) | ||
| target_sources(app PRIVATE ${app_sources}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| .. zephyr:code-sample:: zbus-async-listeners | ||
| :name: zbus Async Listeners | ||
| :relevant-api: zbus_apis | ||
|
|
||
| Demonstrate the usage of zbus async listeners. | ||
|
|
||
| Overview | ||
| ******** | ||
| This sample demonstrates how to use zbus asynchronous listeners by implementing a simple | ||
| application. The main thread submits an event to a channel that has three listeners: (i) a | ||
| conventional listener, (ii) an asynchronous listener that utilizes the system's work queue, and | ||
| (iii) an asynchronous listener that employs an isolated work queue. | ||
|
|
||
|
|
||
| Building and Running | ||
| ******************** | ||
|
|
||
| This project outputs to the console. It can be built and executed | ||
| on QEMU as follows: | ||
|
|
||
| .. zephyr-app-commands:: | ||
| :zephyr-app: samples/subsys/zbus/async_listeners/ | ||
| :host-os: unix | ||
| :board: qemu_x86 | ||
| :goals: run | ||
|
|
||
| Sample Output | ||
| ============= | ||
|
|
||
| .. code-block:: console | ||
|
|
||
| I: Output | Thread Context | ||
| I: ============================================= | ||
| I: From listener -> Evt=0 | main | ||
| I: From async listener -> Evt=0 | sysworkq | ||
| I: From async listener -> Evt=0 | My work queue | ||
| I: From listener -> Evt=1 | main | ||
| I: From async listener -> Evt=1 | sysworkq | ||
| I: From async listener -> Evt=1 | My work queue | ||
| I: From listener -> Evt=2 | main | ||
| I: From async listener -> Evt=2 | sysworkq | ||
| I: From async listener -> Evt=2 | My work queue | ||
| I: From listener -> Evt=3 | main | ||
| I: From async listener -> Evt=3 | sysworkq | ||
| I: From async listener -> Evt=3 | My work queue | ||
| I: ============================================= | ||
| I: From listener -> Evt=0 | main | ||
| I: From async listener -> Evt=0 | sysworkq | ||
| I: From async listener -> Evt=0 | My work queue | ||
| I: From listener -> Evt=1 | main | ||
| I: From async listener -> Evt=1 | sysworkq | ||
| I: From async listener -> Evt=1 | My work queue | ||
| I: From listener -> Evt=2 | main | ||
| I: From async listener -> Evt=2 | sysworkq | ||
| I: From async listener -> Evt=2 | My work queue | ||
| I: From listener -> Evt=3 | main | ||
| I: From async listener -> Evt=3 | sysworkq | ||
| I: From async listener -> Evt=3 | My work queue | ||
|
|
||
| Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| CONFIG_LOG=y | ||
| CONFIG_THREAD_NAME=y | ||
| CONFIG_ASSERT=y | ||
| CONFIG_LOG_MODE_MINIMAL=y | ||
| CONFIG_BOOT_BANNER=n | ||
| CONFIG_MAIN_THREAD_PRIORITY=5 | ||
| CONFIG_ZBUS=y | ||
| CONFIG_ZBUS_LOG_LEVEL_INF=y | ||
| CONFIG_ZBUS_CHANNEL_NAME=y | ||
| CONFIG_ZBUS_OBSERVER_NAME=y | ||
| CONFIG_ZBUS_ASYNC_LISTENER=y | ||
| CONFIG_HEAP_MEM_POOL_SIZE=512 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.