-
Notifications
You must be signed in to change notification settings - Fork 1
Timed Tenants #329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AarC10
wants to merge
8
commits into
main
Choose a base branch
from
feature/Aaron/TimedTenants
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Timed Tenants #329
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9f06659
Stub files
AarC10 4cf97b7
Implement methods
AarC10 3b89290
Docs
AarC10 a8d5532
Add ctor for defining timeout for csofttimer
AarC10 84901cc
Timer expiration callback
AarC10 4c69d4d
add todo
AarC10 91164b1
Use uint32 instead of int for CSoftTimer
AarC10 c9cf279
const ctor arg
AarC10 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #ifndef C_TIMED_TENANT_H | ||
| #define C_TIMED_TENANT_H | ||
|
|
||
| #include "f_core/os/c_tenant.h" | ||
| #include "f_core/utils/c_soft_timer.h" | ||
|
|
||
| class CTimedTenant : public CTenant { | ||
| public: | ||
| /** | ||
| * @brief Constructor | ||
| * @param name Name of the tenant | ||
| * @param intervalMillis Interval in milliseconds for the timeout | ||
| */ | ||
| explicit CTimedTenant(const char* name, const uint32_t intervalMillis); | ||
|
|
||
| private: | ||
| CSoftTimer timer; | ||
| }; | ||
|
|
||
| #endif //C_TIMED_TENANT_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #include "f_core/os/tenants/c_timed_tenant.h" | ||
|
|
||
| #include "f_core/os/n_rtos.h" | ||
| #include "zephyr/logging/log.h" | ||
|
|
||
| LOG_MODULE_REGISTER(CTimedTenant); | ||
|
|
||
| static void timerExpirationCallback(struct k_timer* timer) { | ||
| auto* tenant = static_cast<CTimedTenant*>(k_timer_user_data_get(timer)); | ||
| if (tenant != nullptr) { | ||
| tenant->Run(); | ||
| } else { | ||
| LOG_ERR("Timed tenant callback with null tenant"); | ||
| } | ||
| } | ||
|
|
||
| CTimedTenant::CTimedTenant(const char* name, const uint32_t intervalMillis) | ||
| : CTenant(name), timer(intervalMillis, timerExpirationCallback, nullptr) { | ||
| timer.SetUserData(this); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From an abstraction point of view, does this deserve the name tenant?
Before now, tenants were things that were on tasks and managed by StartRTOS/StopRTOS
As far as I can tell, the timed 'tenant' is not run on a task nor is it started/stopped by Start/StopRTOS just by the constructor
Also, I believe the idea of the timer expiry function is that it is 'interrupt-esque' if not fully in an interrupt context

https://docs.zephyrproject.org/latest/kernel/services/timing/timers.html#using-a-timer-expiry-function
To me, Calling this a tenant and having the Run method on it disguises this limitation since all other Run's are not required to be interrupt safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk what the correct place to go from here is tbh,
I think this needs a little more considering before it goes in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair this was like a 15 minute thing to write