Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit 44241b5

Browse files
committed
Adopted rename of underlying C library to equeue
- Avoids conflicts with similarly named libraries/files - Adopts single equeue prefix - Maximizes the vowel to consonant ratio in the name
2 parents c55658f + c82cd96 commit 44241b5

17 files changed

+181
-181
lines changed

.mbedignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
events-c/tests/
1+
equeue/tests/

EventQueue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void EventQueue::break_() {
2525
}
2626

2727
unsigned EventQueue::get_tick() {
28-
return events_tick();
28+
return equeue_tick();
2929
}
3030

3131
void EventQueue::cancel(int id) {

EventQueue.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#ifndef EVENT_QUEUE_H
1717
#define EVENT_QUEUE_H
1818

19-
#include "events-c/events.h"
19+
#include "equeue/equeue.h"
2020
#include "Callback.h"
2121
#include <cstddef>
2222
#include <new>
@@ -28,8 +28,8 @@ namespace events {
2828
* Minimum size of an event
2929
* This size fits a Callback<void()> at minimum
3030
*/
31-
#undef EVENTS_EVENT_SIZE
32-
#define EVENTS_EVENT_SIZE (sizeof(struct event) + sizeof(void*) + sizeof(mbed::Callback<void()>))
31+
#define EVENTS_EVENT_SIZE \
32+
(EQUEUE_EVENT_SIZE - 2*sizeof(void*) + sizeof(mbed::Callback<void()>))
3333

3434
/** DEFAULT_QUEUE_SIZE
3535
* default size of buffer for events
@@ -95,7 +95,7 @@ class EventQueue {
9595
}
9696

9797
F *e = new (p) F(f);
98-
event_dtor(e, &EventQueue::dtor<F>);
98+
equeue_event_dtor(e, &EventQueue::dtor<F>);
9999
return equeue_post(&_equeue, &EventQueue::call<F>, e);
100100
}
101101

@@ -140,8 +140,8 @@ class EventQueue {
140140
}
141141

142142
F *e = new (p) F(f);
143-
event_delay(e, ms);
144-
event_dtor(e, &EventQueue::dtor<F>);
143+
equeue_event_delay(e, ms);
144+
equeue_event_dtor(e, &EventQueue::dtor<F>);
145145
return equeue_post(&_equeue, &EventQueue::call<F>, e);
146146
}
147147

@@ -186,9 +186,9 @@ class EventQueue {
186186
}
187187

188188
F *e = new (p) F(f);
189-
event_delay(e, ms);
190-
event_period(e, ms);
191-
event_dtor(e, &EventQueue::dtor<F>);
189+
equeue_event_delay(e, ms);
190+
equeue_event_period(e, ms);
191+
equeue_event_dtor(e, &EventQueue::dtor<F>);
192192
return equeue_post(&_equeue, &EventQueue::call<F>, e);
193193
}
194194

File renamed without changes.
File renamed without changes.

events-c/Makefile renamed to equeue/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
TARGET = libevents.a
1+
TARGET = libequeue.a
22

33
CC = gcc
44
AR = ar

events-c/README.md renamed to equeue/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
## Events ##
1+
## The equeue library ##
22

3-
The events library provides a flexible event queue implementation
4-
that acts as a drop in scheduler and framework for composable event
5-
loops.
3+
The equeue library provides a composable event queue implementation
4+
that acts as a drop in scheduler and event framework.
65

76
``` c
8-
#include "events.h"
7+
#include "equeue.h"
98
#include <stdio.h>
109

1110
void print(void *s) {
@@ -15,12 +14,12 @@ void print(void *s) {
1514
int main() {
1615
// creates a queue with space for 32 basic events
1716
equeue_t queue;
18-
equeue_create(&queue, 32*EVENTS_EVENT_SIZE);
17+
equeue_create(&queue, 32*EQUEUE_EVENT_SIZE);
1918

2019
// events are simple callbacks
2120
equeue_call(&queue, print, "called immediately");
22-
equeue_call_in(&queue, print, "called in 2 seconds", 2000);
23-
equeue_call_every(&queue, print, "called every 1 seconds", 1000);
21+
equeue_call_in(&queue, 2000, print, "called in 2 seconds");
22+
equeue_call_every(&queue, 1000, print, "called every 1 seconds");
2423

2524
// events are executed when dispatch is called
2625
equeue_dispatch(&queue, 3000);
@@ -32,14 +31,14 @@ int main() {
3231
}
3332
```
3433
35-
The events library can be used for normal event loops, however it also
36-
supports multithreaded environments. More information on the idea
37-
behind composable event loops
34+
The equeue library can be used for a normal event loops, however it also
35+
supports composition and multithreaded environments. More information on
36+
the idea behind composable event loops
3837
[here](https://gist.github.com/geky/4969d940f1bd5596bdc10e79093e2553).
3938
4039
## Tests ##
4140
42-
The events library uses a set of local tests based on the posix implementation.
41+
The equeue library uses a set of local tests based on the posix implementation.
4342
4443
Runtime tests are located in [tests.c](tests/tests.c):
4544
@@ -63,6 +62,6 @@ cat results.txt | make prof
6362
## Porting ##
6463

6564
The events library requires a small porting layer:
66-
- [events_tick](events_tick.h) - monotonic counter
67-
- [events_mutex](events_mutex.h) - non-recursive mutex
68-
- [events_sema](events_sema.h) - binary semaphore
65+
- [equeue_tick](equeue_tick.h) - monotonic counter
66+
- [equeue_mutex](equeue_mutex.h) - non-recursive mutex
67+
- [equeue_sema](equeue_sema.h) - binary semaphore

0 commit comments

Comments
 (0)