This repository has been archived by the owner on Aug 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced events-c lib with the contents of it
- Loading branch information
1 parent
3cfbc4d
commit c621d7f
Showing
12 changed files
with
709 additions
and
1 deletion.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ROOT=. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright (c) 2016 Christopher Haster | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
MBED = mbed | ||
TOOLCHAIN = GCC_ARM | ||
MCU = K64F | ||
|
||
MFLAGS += -j 4 | ||
ifdef VERBOSE | ||
MFLAGS += -v | ||
endif | ||
ifdef DEBUG | ||
MFLAGS += -o debug-info | ||
endif | ||
|
||
all: | ||
$(MBED) compile $(MFLAGS) -t $(TOOLCHAIN) -m $(MCU) $(addprefix --source=, . $(SRC)) | ||
|
||
clean: | ||
rm -rf .build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## Events ## | ||
|
||
The events library provides a flexible event queue implementation | ||
that acts as a drop in scheduler and framework for composable event | ||
loops. | ||
|
||
``` c | ||
#include "events.h" | ||
#include <stdio.h> | ||
|
||
void print(void *s) { | ||
puts((const char *)s); | ||
} | ||
|
||
int main() { | ||
// creates a queue with 32 events with default size | ||
struct equeue queue; | ||
equeue_create(&queue, 32, 0); | ||
|
||
// events are simple callbacks | ||
event_call(&queue, print, "called immediately"); | ||
event_call_in(&queue, print, "called in 2 seconds", 2000); | ||
event_call_every(&queue, print, "called every 1 seconds", 1000); | ||
|
||
// events are executed when dispatch is called | ||
equeue_dispatch(&queue, 3000); | ||
|
||
print("called after 3 seconds"); | ||
|
||
// dispatch can be called in an infinite loop | ||
equeue_dispatch(&queue, -1); | ||
} | ||
``` | ||
The events library can be used for normal event loops, however it also | ||
supports multithreaded environments. More information on the idea | ||
behind composable event loops | ||
[here](https://gist.github.com/geky/4969d940f1bd5596bdc10e79093e2553). | ||
## Porting ## | ||
The events library only requires the following: | ||
- monotonic counter | ||
- non-recursive mutex | ||
- binary semaphore | ||
Supported implementations are hosted as branches on this repo: | ||
- Posix | ||
- mbed |
Oops, something went wrong.