FastLED 3.9.15
Loading...
Searching...
No Matches
transaction.h
Go to the documentation of this file.
1#pragma once
2
8
9#include "fl/stl/limits.h"
10#include "fl/stl/stdint.h"
11#include "fl/stl/unique_ptr.h"
12#include "fl/stl/result.h"
13#include "fl/stl/optional.h"
14#include "fl/task/promise.h" // for fl::task::Error
15#include "fl/stl/noexcept.h"
16
17namespace fl {
18
19// Forward declaration for SPIError
20enum class SPIError : u8;
21
22namespace spi {
23
24// Forward declaration
25class Device;
26
27// Type alias for SPI-specific Result type (matches spi.h)
28template<typename T>
30
31// ============================================================================
32// Transaction Class (Async Operations)
33// ============================================================================
34
39public:
43 bool wait(u32 timeout_ms = (fl::numeric_limits<u32>::max)());
44
47 bool isDone() const;
48
51 bool isPending() const;
52
56 bool cancel();
57
62
66
67 // Move semantics
70
71private:
72 friend class Device;
73
74 // Private constructor for Device to create transactions
76
77 struct Impl;
79
80 // Non-copyable
82 Transaction& operator=(const Transaction&) FL_NOEXCEPT = delete;
83};
84
85} // namespace spi
86} // namespace fl
Single-channel SPI device interface (TX-only, transaction-based, optimized for FastLED)
Definition device.h:48
Transaction() FL_NOEXCEPT
fl::unique_ptr< Impl > pImpl
Definition transaction.h:78
bool cancel()
Cancel pending transaction (if supported by platform)
bool isPending() const
Check if transaction is still in progress.
friend class Device
Definition transaction.h:72
Transaction(Transaction &&other) FL_NOEXCEPT
~Transaction()
Destructor - automatically waits for completion.
Transaction & operator=(Transaction &&other) FL_NOEXCEPT
bool isDone() const
Check if transaction is complete.
fl::optional< fl::task::Error > getResult() const
Get result of completed transaction.
bool wait(u32 timeout_ms=(fl::numeric_limits< u32 >::max)())
Wait for transaction to complete.
fl::result< T, SPIError > Result
Definition transaction.h:29
unsigned char u8
Definition stdint.h:131
Optional< T > optional
Definition optional.h:16
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
Base definition for an LED controller.
Definition crgb.hpp:179
Promise-based fluent API for FastLED - standalone async primitives.
result<T, E> type alias for fl::expected (Rust-style naming)
#define FL_NOEXCEPT
static constexpr T max() FL_NOEXCEPT
Definition limits.h:108
Private implementation data for Transaction class.
Definition impl.h:65