4#ifndef SYMBIAN_CONCURRENCY_PROPERTY_WATCH_H_
5#define SYMBIAN_CONCURRENCY_PROPERTY_WATCH_H_
12#include <absl/base/nullability.h>
17#if __has_include(<symbian/runtime.h>)
18#include <symbian/runtime.h>
37 absl::Status
Open(
int category,
unsigned int key) {
38 if (closed_ || native_ !=
nullptr) {
39 return absl::FailedPreconditionError(
"Property owner already opened");
43 "RProperty define and attach");
47 if (closed_ || native_ ==
nullptr) {
49 absl::FailedPreconditionError(
"Property owner is closed"));
51 if (current_ !=
nullptr) {
53 absl::FailedPreconditionError(
"Property request already pending"));
55 auto entry = std::make_shared<Entry>();
57 entry->promise.SetCancellationCallback(
58 [entry = std::weak_ptr<Entry>(entry),
wake = wake_] {
59 if (
auto owned = entry.lock()) {
60 owned->cancel_requested.store(true, std::memory_order_release);
68 entry->promise.SetError(
75 if (closed_ || native_ ==
nullptr) {
76 return absl::FailedPreconditionError(
"Property owner is closed");
83 auto entry = current_;
84 if (closed_ || entry ==
nullptr) {
87 if (entry->cancel_requested.load(std::memory_order_acquire)) {
97 entry->promise.SetValue(
value);
99 entry->promise.SetError(
110 if (native_ !=
nullptr) {
114 if (
auto entry = std::move(current_); entry !=
nullptr) {
115 entry->promise.SetError(absl::CancelledError(
"Property owner closed"));
122 std::atomic<bool> cancel_requested{
false};
125 std::function<void()> wake_;
127 std::shared_ptr<Entry> current_;
128 bool closed_ =
false;
void SymbianRuntimePropertyClose(SymbianRuntimePropertyState *absl_nullable state)
Definition sdk_property.cc:102
void SymbianRuntimePropertyCancel(SymbianRuntimePropertyState *absl_nullable state)
Definition sdk_property.cc:95
int SymbianRuntimePropertyCreate(int category, unsigned int key, SymbianRuntimePropertyState *absl_nullable *absl_nonnull state)
Definition sdk_property.cc:17
int SymbianRuntimePropertySubscribe(SymbianRuntimePropertyState *absl_nullable state)
Definition sdk_property.cc:49
int SymbianRuntimePropertyResult(SymbianRuntimePropertyState *absl_nullable state, int *absl_nullable value)
Definition sdk_property.cc:75
bool SymbianRuntimePropertyIsReady(const SymbianRuntimePropertyState *absl_nullable state)
Definition sdk_property.cc:70
int SymbianRuntimePropertySet(SymbianRuntimePropertyState *absl_nullable state, int value)
Definition sdk_property.cc:62
Definition bounded_channel.h:41
Definition property_watch.h:28
absl::Status Open(int category, unsigned int key)
Definition property_watch.h:37
Future< int > Next()
Definition property_watch.h:46
absl::Status Set(int value)
Definition property_watch.h:74
PropertyWatch(std::function< void()> wake)
Definition property_watch.h:30
void Close()
Definition property_watch.h:105
~PropertyWatch()
Definition property_watch.h:35
bool DispatchReady()
Definition property_watch.h:82
PropertyWatch & operator=(const PropertyWatch &)=delete
PropertyWatch(const PropertyWatch &)=delete
Definition native_camera_stream.cc:19
Definition bounded_channel.h:35
constexpr int kNone
Definition native_status.h:26
absl::Status StatusFromNativeError(int native_code, absl::string_view operation)
Definition native_status.h:44
Definition sdk_property.cc:9
libusb_context *absl_nullable value
Definition usb.cc:37