Dawn Framework 1.0
Universal data acquisition framework for embedded systems
notifier.hxx
1// dawn/include/dawn/io/notifier.hxx
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5
6#pragma once
7
8#include <poll.h>
9
10#include <atomic>
11#include <mutex>
12
13#include "dawn/common/thread.hxx"
14#include "dawn/io/factory.hxx"
15#include "dawn/io/inotifier.hxx"
16#include "dawn/porting/config.hxx"
17
18namespace dawn
19{
20// Forward declaration
21
22struct io_ddata_t;
23
30class CIONotifier final : public IIONotifier
31{
32public:
34 : pfds(nullptr)
35 , pfdsLen(0)
36 , pfdsUpdate(false)
37 , threadCtl()
38 {
39 }
40
42
43 void setThreadConfig(const CThreadedObject::SThreadConfig &config)
44 {
45 threadCtl.setThreadConfig(config);
46 }
47
48 void setThreadStackSize(size_t stackSize)
49 {
50 threadCtl.setThreadStackSize(stackSize);
51 }
52
53 void setThreadPriority(int priority)
54 {
55 threadCtl.setThreadPriority(priority);
56 }
57
58 void setThreadScheduler(int scheduler)
59 {
60 threadCtl.setThreadScheduler(scheduler);
61 }
62
63 int regNotifier(SIONotifier n) override;
64 int notifyData(CIOCommon *io, io_ddata_t *data) override;
65 int start();
66 int stop();
67
68private:
69 struct
70 {
71 std::vector<SIONotifier> user;
72 io_ddata_t *data;
73 size_t batch;
74 } typedef SIONotifierPriv;
75
76 std::vector<SIONotifierPriv> vnote;
77 struct pollfd *pfds;
78 size_t pfdsLen;
79 std::atomic_bool pfdsUpdate;
80 std::mutex pfdsLock;
81
82 CThreadedObject threadCtl;
83
84 void updatePfds();
85 void thread();
86};
87} // Namespace dawn
Base class for all I/O objects.
Definition common.hxx:27
I/O notification handler with poll-based event delivery.
Definition notifier.hxx:31
int notifyData(CIOCommon *io, io_ddata_t *data)
Emit an immediate notification for already-available data.
Definition notifier.cxx:306
int regNotifier(SIONotifier n)
Register I/O notification callback.
Definition notifier.cxx:232
Portable thread owner abstraction for Dawn components.
Definition thread.hxx:32
void setThreadScheduler(int scheduler)
Configure worker thread scheduler policy.
Definition thread.hxx:169
void setThreadStackSize(size_t stackSize)
Configure worker thread stack size.
Definition thread.hxx:129
void setThreadPriority(int priority)
Configure worker thread priority.
Definition thread.hxx:149
void setThreadConfig(const SThreadConfig &config)
Replace the full thread configuration.
Definition thread.hxx:109
Abstract interface for registering asynchronous I/O notification.
Definition inotifier.hxx:25
Out-of-tree user-extension hooks for Dawn.
Definition bindable.hxx:13
Per-thread runtime configuration.
Definition thread.hxx:55
Notifier registration structure.
Definition inotifier.hxx:46
Heap-allocated dynamic I/O data buffer.
Definition ddata.hxx:21