Skip to content

Commit 99ca88a

Browse files
committed
events: Added support for infering event type from Callback objects
While limitations in type inference prevent the event helper from infering the type of generic function objects, there is nothing technical preventing inference from the Callback class, where the function type is encoded in the template parameters. With adoption of the Callback class as the standard function representation, it makes sense to support events created from callback objects.
1 parent 21b91c7 commit 99ca88a

File tree

3 files changed

+405
-2
lines changed

3 files changed

+405
-2
lines changed

TESTS/events/queue/main.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void event_class_helper_test() {
210210

211211
void event_inference_test() {
212212
counter = 0;
213-
EventQueue queue (2048);
213+
EventQueue queue(2048);
214214

215215
queue.event(count5, 1, 1, 1, 1, 1).post();
216216
queue.event(count5, 1, 1, 1, 1).post(1);
@@ -219,9 +219,16 @@ void event_inference_test() {
219219
queue.event(count5, 1).post(1, 1, 1, 1);
220220
queue.event(count5).post(1, 1, 1, 1, 1);
221221

222+
queue.event(callback(count5), 1, 1, 1, 1, 1).post();
223+
queue.event(callback(count5), 1, 1, 1, 1).post(1);
224+
queue.event(callback(count5), 1, 1, 1).post(1, 1);
225+
queue.event(callback(count5), 1, 1).post(1, 1, 1);
226+
queue.event(callback(count5), 1).post(1, 1, 1, 1);
227+
queue.event(callback(count5)).post(1, 1, 1, 1, 1);
228+
222229
queue.dispatch(0);
223230

224-
TEST_ASSERT_EQUAL(counter, 30);
231+
TEST_ASSERT_EQUAL(counter, 60);
225232
}
226233

227234

0 commit comments

Comments
 (0)