Skip to content
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

event_periodic_callback: add event_periodic_callback_create() #20459

Merged
merged 2 commits into from
Mar 18, 2024

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Mar 12, 2024

Contribution description

Creating a periodic event should be no more difficult than creating a thread, so add a event_periodic_callback_create() convenience functions that reduces creating and starting a periodic event to a single function.

Testing procedure

Read the API to see if this is really a worthwhile improvement.

Issues/PRs references

After seeing many threads being created for simple periodic measurements, maybe this could be a remedy.

@github-actions github-actions bot added the Area: sys Area: System label Mar 12, 2024
@Teufelchen1
Copy link
Contributor

After seeing many threads...

Do you have an example? Can you refactor some code?
Can you also fix the typo in line 57 "..to to..."?

Reads fine, lgtm.

@benpicco
Copy link
Contributor Author

benpicco commented Mar 12, 2024

Do you have an example? Can you refactor some code?

I unfortunately can't since that's code by a customer, but I also want to spare your eyes.
But they basically do multiple instances of

static void *_adc_thread(void *ctx)
{
    (void)ctx;

    while (1) {
        do_measure();
        send_data();
        ztimer_sleep():
    }
    return NULL;
}

If I can get them to instead do

static void _adc_event(void *ctx)
{
    do_measure();
    send_data();
}

that would be a win for everyone.

@Teufelchen1
Copy link
Contributor

Ah, forgot to ask for squashing 😅

@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 12, 2024
@benpicco
Copy link
Contributor Author

eh but those are two distinct commits

@Teufelchen1
Copy link
Contributor

well....if you insist 😀

@riot-ci
Copy link

riot-ci commented Mar 12, 2024

Murdock results

✔️ PASSED

2bef44b event_periodic_callback: fix typo

Success Failures Total Runtime
10008 0 10009 07m:51s

Artifacts

@Teufelchen1 Teufelchen1 added this pull request to the merge queue Mar 12, 2024
@kfessel
Copy link
Contributor

kfessel commented Mar 12, 2024

very convenient

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 12, 2024
@mguetschow mguetschow added this pull request to the merge queue Mar 18, 2024
Merged via the queue into RIOT-OS:master with commit 3aaea1a Mar 18, 2024
27 checks passed
@benpicco benpicco deleted the event_periodic_callback_create branch March 18, 2024 16:32
@MrKevinWeiss MrKevinWeiss added this to the Release 2024.04 milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants