The work_queue sample illustrates three reaction styles available for using zbus. The first is a listener that reacts by callback; use it should for urgent reaction. The second is a listener that responds by callback; instead of executing the code, it pushes a job to a work queue that will be executed shortly but not immediately. The last one is the subscriber that reacts using a queue; use it for an asynchronous reaction where the developer would like to control the flow. Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
32 lines
1.8 KiB
YAML
32 lines
1.8 KiB
YAML
sample:
|
|
name: Work queue
|
|
common:
|
|
tags: zbus
|
|
harness: console
|
|
harness_config:
|
|
type: multi_line
|
|
ordered: false
|
|
regex:
|
|
- "I: Sensor msg processed by CALLBACK fh1: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by CALLBACK fh2: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by CALLBACK fh3: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh1: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh2: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh3: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by THREAD handler 1: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by THREAD handler 2: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by THREAD handler 3: temp = 10, press = 1, humidity = 100"
|
|
- "I: Sensor msg processed by CALLBACK fh1: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by CALLBACK fh2: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by CALLBACK fh3: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh1: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh2: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by WORK QUEUE handler dh3: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by THREAD handler 1: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by THREAD handler 2: temp = 20, press = 2, humidity = 200"
|
|
- "I: Sensor msg processed by THREAD handler 3: temp = 20, press = 2, humidity = 200"
|
|
|
|
tests:
|
|
sample.zbus.work_queue:
|
|
tags: zbus
|