Skip to content

event_periodic_callback: add event_periodic_callback_create()#20459

Merged
mguetschow merged 2 commits intoRIOT-OS:masterfrom
benpicco:event_periodic_callback_create
Mar 18, 2024
Merged

event_periodic_callback: add event_periodic_callback_create()#20459
mguetschow merged 2 commits intoRIOT-OS:masterfrom
benpicco:event_periodic_callback_create

Conversation

@benpicco
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

eh but those are two distinct commits

@Teufelchen1
Copy link
Copy Markdown
Contributor

well....if you insist 😀

@Teufelchen1 Teufelchen1 enabled auto-merge March 12, 2024 17:52
@riot-ci
Copy link
Copy Markdown

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
Copy Markdown
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
@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