Commit Graph

95 Commits (27571bc2d7a682293a0f4a4f2fc201b3fb972158)

Author SHA1 Message Date
Teppo Järvelin 719117e12c Fix EventQueue::cancel to return value 2019-08-20 15:56:41 +03:00
Hugues Kamba f0f408b2d8 Upstream PR #11073 review request changes (#11135)
* Modify Doxygen grouping of `drivers` Public/Internal APIs
* Correct classification of `mbed_events.h`
* Amend name of Doxygen group containing Device Key API
* Classify `CallChain.h` as public API and relocate file
* Remove Doxygen group from `equeue_platform.h` as it has no Doxygen compliant documentation
* Move USB target specific code back to `usb/device/targets`
2019-08-02 12:32:40 +01:00
Hugues Kamba 20f81e19be Change Doxygen groups structure, splitting first by Public/Internal (#11105)
* Change Doxygen groups structure, splitting first by Public/Internal

This commit also does the following:
* groups the documentation of related API
* moves `events/internal/equeue.h` to `events/equeue.h`
* merges `events/source/README.md` to `events/README.md`
2019-08-02 12:23:47 +01:00
Hugues Kamba bfa1b4dd84 Drivers/Events/RTOS Public and internal APIs cleanup (#10955)
Separate drivers, events, and rtos internal APIs from public APIs.

* Move source files to source subdirs
* Move internal headers to internal subdirs
* Add Doxygen comments for documenting internal and public APIs
* Remove source code from header files in order to remove include pre-processor directives
that included header files not directly used by said header files
* Explicitly include header files instead of implicit inclusions via third-party header files.

Release Notes

This will break user code that was using an internal API as the internal header files have been moved.
This will only break if the user was including the header file using a namespace (i.e #include "foo/bar.h" instead of #include "bar.h"
2019-08-02 12:23:47 +01:00
Seppo Takalo 987533859a
Merge pull request #10104 from kjbracey-arm/sleep_api
Sleep rework, RTOS API for bare metal, wait deprecations
2019-07-17 14:37:53 +03:00
Kevin Bracey 163fb19d97 events: Don't use OsTimer in SysTick builds
Previous fix assumed OsTimer is in use - it is for tickless RTOS builds
and non-RTOS builds, but non-tickless RTOS builds avoid it altogether
and use the SysTick peripheral.

Restore previous behaviour for those builds, and just always read the
tick count - there is no downside to this when ticking.

While in the code, make equeue_tick initialisation explicit. This was
problem if the OsTimer is not yet initialised when th
done while debugging - turns out not to be part of the fix, but it
speeds up the runtime code.
2019-07-16 14:38:08 +03:00
Kevin Bracey 7442da30f9 equeue - avoid Kernel::get_ms_count from IRQ
Kernel::get_ms_count is documented as not working from IRQ.

In RTOS builds it can return misleading answers - see
https://github.com/ARM-software/CMSIS_5/issues/625

In non-RTOS builds, it can trigger an assert, as it upsets the
sleep logic.

Modified code is still not ideal - could be improved further if
there was a fast path for "post now" that didn't bother looking
at timers (both at post time and dispatch time).
2019-07-15 10:13:50 +03:00
Kevin Bracey c94d6a8cc7 Make events use RTOS API
Switch from CMSIS-RTOS to mbed C++ API, which are available in bare
metal build.

Other minor tidies, like removing unnecessary volatile.
2019-07-15 10:13:50 +03:00
Kevin Bracey 013377a857 Revert back to non-variadic binding
Unwind previous commit and restore original behaviour for binding,
pending further investigation.

Some functions like `EventQueue::call` require precisely matching
argument types to get the correct overload, as before.

Others like `EventQueue::event` permit compatible types for binding, and
those handle the 0-5 bound arguments non-variadically in order to
correctly locate the free arguments in deduction.
2019-06-26 11:52:25 +03:00
Kevin Bracey 62062efc37 Constrain context argument types
Previous commit just replaced instances of "class B0, class B1, class
C0, class C1" with "class... BoundArgs, class... ContextArgs".

This loses the requirement that the numbers must match.

Now, the original code was also inconsistent as to whether it used
separate types for the target function and the call input parameters.
Some forms just used B0, B1 as parameters rather than separate C0, C1.

I believe the separate parameters would have been primarily to avoid
template deduction confusion - eg if int was supplied to a B0 parameter
but the function took char as B0, there would be an ambiguity. But the
fix didn't seem to be fully applied.

Rewritten all templates parameterising on function pointer type and
input arguments so that they use `type_identity_t<BoundArgTs>...` as
input parameters to match the target function.

This has the subtle effect that any conversion happens at invocation,
before storing to the context, rather than when the context calls the
target.
2019-06-25 14:47:03 +03:00
Kevin Bracey 4d9148a9dc Reduce Event.h and EventQueue.h using C++11
Variadic templates can reduce Event.h from 4,100 lines to 300, and
EventQueue.h from 3,400 to 1,000, so 6,000 lines saved total.

End result isn't totally variadic, as we still need specialisations
for storing 0-5 values in contexts, but that specialisation is now
in exactly one place.

Only change other from switching to variadic templates is using
delegating constructors instead of the `new (this)` trick. That trick is
still used in the assignment operator.

Minor documentation correction. It's possible that the separate
simplified variadic Doxygen version not be needed now, but I've left it.
2019-06-25 13:48:39 +03:00
Kevin Bracey db18c2252e equeue: align passed-in buffer
Make equeue_create_inplace align the passed-in buffer and size to
sizeof(void *).

Really we should be aiming to align more for ARM, as blocks should be
8-byte aligned, but the internal heap mechanisms only work to 4-byte
alignment at the moment. More work would be needed to ensure 8-byte
alignment of allocated blocks.
2019-04-03 18:29:54 +03:00
Veijo Pesonen 5caed17aee events.shared-eventsize: increased from 256B to 768B
Original value was too small once both ESP8266 driver and
asynchronous DNS started to use shared event queue. An assumption is
made that once shared event queue is taken into use there are going to
be multiple users instead of one, for which the original value would
have been sufficient.
2019-02-26 09:44:15 +02:00
Amanda Butler e7384b09c3
Edit README.md
Edit file, mostly for active voice.
2019-01-09 05:08:55 -06:00
Veijo Pesonen 30a1dd8090 Increases events.shared-stacksize to 2K
ESP8266 driver started to use global event queue to handle some AT
parsing and call Socket::sigio() events. It turned out that when
running DNS tests, or Pelion Client, the stack space (1kB) is not
enough for the purpose.

Therefore we propose that this is raised to 2kB, as the assumption
is that event loop should allow as equivalently complex code than
any other threads.

In Mbed OS, the default Thread stack size is 4kB, but we assume 2kB
to be enough for non-blocking event purposes.
2019-01-04 14:35:46 +02:00
Martin Kojtal ad76c94369
Merge pull request #9066 from deepikabhavnani/equeue_chain_fixed
Equeue chaining bug fixes
2019-01-02 09:16:19 +00:00
deepikabhavnani 12623ace8b Added test case for verification 2018-12-19 21:54:48 -06:00
deepikabhavnani 01b2530a7d Corrected destructor loop to clear all pending events
In `equeue_destroy` the external loop was for main events linked
list and internal loop for siblings.
Siblings start was not initialized correctly for each main link
2018-12-19 11:59:42 -06:00
deepikabhavnani b893d5681f Old pointers of sibling were not cleared
When adding sibling at the head of linked list, the head if pointing
to something in linked list was not updated, hence a loop was formed
in linked list

Element0 - First addition to linked list
Element1 - Has higher delay hence added to back
0 ->(next) 1
Element2 - Delay is same as Element0, hence should be sibling of 0
           Shall be added at head

Expected:
2    ------------->(next) 1
|(sibling)
0

Bug: (Resolved with this)
2    ------------->(next) 1
|(sibling)
0    ------------->(next) 1

If we add more elements and next pointer of sibling is updated, old
references will cause issues
Element3 added

Expected:
2    ------------->(next) 3  ------------->(next) 1
|(sibling)
0

Bug: (Resolved with this)
2    ------------->(next) 3  ------------->(next) 1
|(sibling)
0    ------------->(next) 1
***Both siblings here point to different next***
2018-12-18 17:23:02 -06:00
deepikabhavnani 87c557c288 Return error in case chaining fails 2018-12-14 09:33:16 -06:00
deepikabhavnani 03853597f5 Memory allocated from parent queue was freed/added to chained queue.
Issue was seen with below example
EventQueue q1;
EventQueue q2;

void main() {
while( true ) {
q1.chain( &q2 ); // Chain q2 to q1
q1.chain( NULL ); // Remove chain from q1
//This second step should free the memory from the chained q2 event.
}
}

Memory allocated from q1 slab was freed for q2, which will result in
memory leak.
2018-12-11 16:25:50 -06:00
deepikabhavnani 5f0912276b Check is allocation in event queue was success or not, and
report error / assert when allocation fails.
2018-12-11 16:24:57 -06:00
Martin Kojtal 1303e143e6 events: add spdx license 2018-11-28 10:39:52 +00:00
deepikabhavnani b6e381b701 MBED_NO_GLOBAL_USING_DIRECTIVE is added to remove auto-addition of namespace
Macro guard `MBED_NO_GLOBAL_USING_DIRECTIVE` is added around namespace, to avoid
polluting users namespace.
2018-11-26 09:23:16 -06:00
Martin Kojtal d3e51fc3a0 events: fix coding style 2018-11-15 07:20:13 +00:00
Martin Kojtal add417221c events: fix events coding style 2018-11-08 08:54:37 +00:00
Cruz Monrreal c792d33112
Merge pull request #8652 from 0xc0170/dev_rollup
Rollup PR for docs
2018-11-06 20:40:04 -06:00
Jeroen de Bruijn 467a7b6344
feat: Add name to shared queue threads 2018-11-02 13:52:18 +01:00
kegilbert ae673d606c Fix typos in Events doxygen 2018-11-01 15:40:44 -05:00
Cruz Monrreal de6ba91644
Merge pull request #8365 from 0xc0170/fix_astyle_common2
Fix astyle for tests folders
2018-10-25 10:41:13 -05:00
Cruz Monrreal 9c59d9acc3
Merge pull request #7864 from deepikabhavnani/remove_mbed_h
Add required header file and namespace element instead add all.
2018-10-25 09:26:24 -05:00
Martin Kojtal 08b94aa193 events: fix astyle 2018-10-25 09:58:18 +01:00
Jaakko Korhonen 0d278e7cee
EventQueue documentation fix. 2018-10-18 11:21:58 +03:00
Deepika fdcd51d6a7 EventQueue: Add required header file and namespace element instead add all 2018-10-15 10:39:41 -05:00
Kevin Gilbert 1c74c30aee
Remove protected class from EventQueue Doxy 2018-10-12 13:38:40 -05:00
Martin Kojtal 05b2d6e785
Merge pull request #7810 from kegilbert/eventqueue-templatewall-rework
Eventqueue Templatewall Doxygen Rework
2018-08-24 11:30:54 +02:00
Amanda Butler 935db68ca3
Copy edit EventQueue.h
Copy edit file for consistent capitalization, tense and voice.
2018-08-20 11:39:37 -05:00
kegilbert 383b464cf8 Final cleanup of eventqueue doxy comments 2018-08-16 17:19:57 -05:00
kegilbert a08ade30d4 Finish basic examples for all eventqueue methods 2018-08-16 17:19:57 -05:00
kegilbert c802f77258 Add inline doxy examples for eventqueue method calls 2018-08-16 17:19:57 -05:00
kegilbert 04fe577329 Patch EventQueue doxygen to remove templatewall
In the doxygen only segment define generic function declarations for the docs

Finished initial rework, pending TODOs for param comments
2018-08-16 17:19:57 -05:00
Christopher Haster 7efb517f89
equeue: Fixed overflow in rtos-less timeout code
Thanks to simonnilsson
2018-08-13 22:19:46 -05:00
Martin Kojtal 8b379703d4 events: astyle fix 2018-08-03 13:23:38 +01:00
Kimmo Vaisanen 990da085d9 Introduce API to query how much time is left for delayed event
If user has initiated a delayed event (either with call_in or call_every),
user might need to know how much time is left until the event is
due to be dispatched.

Added time_left() function can be used to get the remaining time.
2018-05-18 12:55:06 +03:00
Kevin Bracey d979c59118 Make event queue use RTOS tick count
Event queue was using its own Timer or LowPowerTimer objects to derive
millisecond tick counts. This is unnecessary in RTOS builds, where the
RTOS is maintaining a tick count.

It also makes more sense to use the actual RTOS tick count, as the
values are being used to compute tick timeouts for RTOS calls. Computing
these RTOS tick delays with a separate timer could conceivably lead to
rounding errors.

Fixes: #5378
2018-04-20 11:44:36 +03:00
Cruz Monrreal 15807744de
Merge pull request #6238 from pauluap/break_dispatch_flag
Remove windup behavior from break_dispatch
2018-03-15 10:59:36 -05:00
Cruz Monrreal 9cac3b2f6b
Merge pull request #6149 from bmcdonnell-ionx/typos
Fix typos in the files
2018-03-15 10:53:03 -05:00
Cruz Monrreal b97c7d8263
Merge pull request #6274 from geky/events-doc-periodic
events: Added note about immediate firing of periodic events
2018-03-15 10:48:22 -05:00
Martin Kojtal 87b37c0e2a
Merge pull request #6286 from delftswa2018/feature-typo-fixes
Small typo fixes in readme.md files
2018-03-08 17:36:23 +01:00
Jasper de Winkel 2c7a25a949 Small typo fixes in readme.md files 2018-03-06 19:07:03 +01:00