1.. zephyr:code-sample:: zbus-work-queue 2 :name: Work queue 3 :relevant-api: zbus_apis 4 5 Use a work queue to process zbus messages in various ways. 6 7Overview 8******** 9This sample implements an application using zbus to illustrate three different reaction options. First, the observer can react "instantaneously" by using a listener callback. It can schedule a job, pushing that to the system work queue. Last, it can wait and execute that in a subscriber thread. 10 11Building and Running 12******************** 13 14This project outputs to the console. It can be built and executed 15on QEMU as follows: 16 17.. zephyr-app-commands:: 18 :zephyr-app: samples/subsys/zbus/work_queue 19 :host-os: unix 20 :board: qemu_x86 21 :goals: run 22 23Sample Output 24============= 25 26.. code-block:: console 27 28 I: Sensor msg processed by CALLBACK fh1: temp = 10, press = 1, humidity = 100 29 I: Sensor msg processed by CALLBACK fh2: temp = 10, press = 1, humidity = 100 30 I: Sensor msg processed by CALLBACK fh3: temp = 10, press = 1, humidity = 100 31 I: Sensor msg processed by WORK QUEUE handler dh1: temp = 10, press = 1, humidity = 100 32 I: Sensor msg processed by WORK QUEUE handler dh2: temp = 10, press = 1, humidity = 100 33 I: Sensor msg processed by WORK QUEUE handler dh3: temp = 10, press = 1, humidity = 100 34 I: Sensor msg processed by THREAD handler 1: temp = 10, press = 1, humidity = 100 35 I: Sensor msg processed by THREAD handler 2: temp = 10, press = 1, humidity = 100 36 I: Sensor msg processed by THREAD handler 3: temp = 10, press = 1, humidity = 100 37 I: Sensor msg processed by CALLBACK fh1: temp = 20, press = 2, humidity = 200 38 I: Sensor msg processed by CALLBACK fh2: temp = 20, press = 2, humidity = 200 39 I: Sensor msg processed by CALLBACK fh3: temp = 20, press = 2, humidity = 200 40 I: Sensor msg processed by WORK QUEUE handler dh1: temp = 20, press = 2, humidity = 200 41 I: Sensor msg processed by WORK QUEUE handler dh2: temp = 20, press = 2, humidity = 200 42 I: Sensor msg processed by WORK QUEUE handler dh3: temp = 20, press = 2, humidity = 200 43 I: Sensor msg processed by THREAD handler 1: temp = 20, press = 2, humidity = 200 44 I: Sensor msg processed by THREAD handler 2: temp = 20, press = 2, humidity = 200 45 I: Sensor msg processed by THREAD handler 3: temp = 20, press = 2, humidity = 200 46 I: Sensor msg processed by CALLBACK fh1: temp = 30, press = 3, humidity = 300 47 I: Sensor msg processed by CALLBACK fh2: temp = 30, press = 3, humidity = 300 48 I: Sensor msg processed by CALLBACK fh3: temp = 30, press = 3, humidity = 300 49 I: Sensor msg processed by WORK QUEUE handler dh1: temp = 30, press = 3, humidity = 300 50 I: Sensor msg processed by WORK QUEUE handler dh2: temp = 30, press = 3, humidity = 300 51 I: Sensor msg processed by WORK QUEUE handler dh3: temp = 30, press = 3, humidity = 300 52 I: Sensor msg processed by THREAD handler 1: temp = 30, press = 3, humidity = 300 53 I: Sensor msg processed by THREAD handler 2: temp = 30, press = 3, humidity = 300 54 I: Sensor msg processed by THREAD handler 3: temp = 30, press = 3, humidity = 300 55 <continues> 56 57Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. 58