4#ifndef SYMBIAN_CONCURRENCY_PROPERTY_WATCH_H_
5#define SYMBIAN_CONCURRENCY_PROPERTY_WATCH_H_
15#if __has_include(<symbian/runtime.h>)
16#include <symbian/runtime.h>
35 absl::Status
Open(
int category,
unsigned int key) {
36 if (closed_ || native_ !=
nullptr) {
37 return absl::FailedPreconditionError(
"Property owner already opened");
41 "RProperty define and attach");
45 if (closed_ || native_ ==
nullptr) {
47 absl::FailedPreconditionError(
"Property owner is closed"));
49 if (current_ !=
nullptr) {
51 absl::FailedPreconditionError(
"Property request already pending"));
53 auto entry = std::make_shared<Entry>();
55 entry->promise.SetCancellationCallback(
56 [entry = std::weak_ptr<Entry>(entry),
wake = wake_] {
57 if (
auto owned = entry.lock()) {
58 owned->cancel_requested.store(true, std::memory_order_release);
66 entry->promise.SetError(
73 if (closed_ || native_ ==
nullptr) {
74 return absl::FailedPreconditionError(
"Property owner is closed");
81 auto entry = current_;
82 if (closed_ || entry ==
nullptr) {
85 if (entry->cancel_requested.load(std::memory_order_acquire)) {
95 entry->promise.SetValue(
value);
97 entry->promise.SetError(
108 if (native_ !=
nullptr) {
112 auto entry = std::move(current_);
113 if (entry !=
nullptr) {
114 entry->promise.SetError(absl::CancelledError(
"Property owner closed"));
121 std::atomic<bool> cancel_requested{
false};
124 std::function<void()> wake_;
126 std::shared_ptr<Entry> current_;
127 bool closed_ =
false;
bool SymbianRuntimePropertyIsReady(const SymbianRuntimePropertyState *state)
Definition sdk_property.cc:68
void SymbianRuntimePropertyClose(SymbianRuntimePropertyState *state)
Definition sdk_property.cc:100
int SymbianRuntimePropertyResult(SymbianRuntimePropertyState *state, int *value)
Definition sdk_property.cc:73
int SymbianRuntimePropertySubscribe(SymbianRuntimePropertyState *state)
Definition sdk_property.cc:47
int SymbianRuntimePropertyCreate(int category, unsigned int key, SymbianRuntimePropertyState **state)
Definition sdk_property.cc:16
int SymbianRuntimePropertySet(SymbianRuntimePropertyState *state, int value)
Definition sdk_property.cc:60
void SymbianRuntimePropertyCancel(SymbianRuntimePropertyState *state)
Definition sdk_property.cc:93
Definition bounded_channel.h:38
Definition property_watch.h:26
absl::Status Open(int category, unsigned int key)
Definition property_watch.h:35
Future< int > Next()
Definition property_watch.h:44
absl::Status Set(int value)
Definition property_watch.h:72
PropertyWatch(std::function< void()> wake)
Definition property_watch.h:28
void Close()
Definition property_watch.h:103
~PropertyWatch()
Definition property_watch.h:33
bool DispatchReady()
Definition property_watch.h:80
PropertyWatch & operator=(const PropertyWatch &)=delete
PropertyWatch(const PropertyWatch &)=delete
Definition exception_count.cc:8
Definition bounded_channel.h:32
constexpr int kNone
Definition native_status.h:24
absl::Status StatusFromNativeError(int native_code, absl::string_view operation)
Definition native_status.h:42
Definition sdk_property.cc:8
libusb_context * value
Definition usb.cc:35