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

Commit

Permalink
Replaced events-c lib with the contents of it
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherjimmy committed Jul 1, 2016
1 parent 3cfbc4d commit c621d7f
Show file tree
Hide file tree
Showing 12 changed files with 709 additions and 1 deletion.
1 change: 0 additions & 1 deletion events-c.lib

This file was deleted.

1 change: 1 addition & 0 deletions events-c/.mbed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ROOT=.
7 changes: 7 additions & 0 deletions events-c/LICENSE
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.
17 changes: 17 additions & 0 deletions events-c/Makefile
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
49 changes: 49 additions & 0 deletions events-c/README.md
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
Loading

0 comments on commit c621d7f

Please sign in to comment.