Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
native_timer.h
Go to the documentation of this file.
1// Copyright 2026 The Symbian SDK Authors.
2// Licensed under the Apache License, Version 2.0.
3// Thread-relative RTimer ownership for a single event-thread request pump.
4
5#ifndef SYMBIAN_CONCURRENCY_NATIVE_TIMER_H_
6#define SYMBIAN_CONCURRENCY_NATIVE_TIMER_H_
7
8#if __has_include(<symbian/runtime.h>)
9
10#include <absl/base/nullability.h>
11#include <symbian/runtime.h>
12#else
13#include "abi.h"
14#endif
15
16namespace symbian::concurrency {
17
19 public:
20 NativeTimer() = default;
21 NativeTimer(const NativeTimer&) = delete;
23
25
26 // Create, arm, inspect and close on the same OS thread. A timer may be
27 // rearmed only after its previous status has completed.
28 int Open() {
29 if (state_ != nullptr) {
30 return -11; // KErrAlreadyExists.
31 }
32 return SymbianRuntimeTimerCreate(&state_);
33 }
34
37 }
38
39 // Cancellation finishes before return; Close and destruction do the same.
40 // Use on the OS thread that opened this timer.
42
43 int Result() const { return SymbianRuntimeTimerResult(state_); }
44
45 bool IsReady() const { return SymbianRuntimeTimerIsReady(state_); }
46
47 void Close() {
48 if (state_ == nullptr) {
49 return;
50 }
52 state_ = nullptr;
53 }
54
55 private:
56 SymbianRuntimeTimerState* absl_nullable state_ = nullptr;
57};
58
59} // namespace symbian::concurrency
60
61#endif // SYMBIAN_CONCURRENCY_NATIVE_TIMER_H_
void SymbianRuntimeTimerClose(SymbianRuntimeTimerState *absl_nullable state)
Definition sdk_timer.cc:95
int SymbianRuntimeTimerResult(const SymbianRuntimeTimerState *absl_nullable state)
Definition sdk_timer.cc:82
bool SymbianRuntimeTimerIsReady(const SymbianRuntimeTimerState *absl_nullable state)
Definition sdk_timer.cc:90
int SymbianRuntimeTimerCreate(SymbianRuntimeTimerState *absl_nullable *absl_nullable state)
Definition sdk_timer.cc:39
void SymbianRuntimeTimerCancel(SymbianRuntimeTimerState *absl_nullable state)
Definition sdk_timer.cc:74
int SymbianRuntimeTimerStart(SymbianRuntimeTimerState *absl_nullable state, int microseconds)
Definition sdk_timer.cc:60
Definition bounded_channel.h:41
Definition native_timer.h:18
int Open()
Definition native_timer.h:28
NativeTimer & operator=(const NativeTimer &)=delete
~NativeTimer()
Definition native_timer.h:24
int Start(int microseconds)
Definition native_timer.h:35
void Close()
Definition native_timer.h:47
bool IsReady() const
Definition native_timer.h:45
NativeTimer(const NativeTimer &)=delete
void Cancel()
Definition native_timer.h:41
int Result() const
Definition native_timer.h:43
Definition bounded_channel.h:35
Definition sdk_timer.cc:33