Skip to content

Commit

Permalink
Cleaned up some out of date comments in examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeDP committed Jul 23, 2019
1 parent 1893401 commit 2d1f1da
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 293 deletions.
33 changes: 0 additions & 33 deletions Samples/Cpp/doggo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,28 @@

static void receive_sleeping(const msg_t *msg, const void *userdata);

/*
* Declare and automagically initialize
* this module as soon as program starts.
*/
MODULE("Doggo");

/*
* This function is automatically called before registering the module.
* Use this to set some global state needed eg: in check() function
*/
static void module_pre_start(void) {
printf("Press 'c' to start playing with your own doggo...\n");
}

/*
* Initializes this module's state;
* returns a valid fd to be polled.
*/
static void init(void) {

}

/*
* Whether this module should be actually created:
* true if module must be created, !true otherwise.
*
* Use this function as a starting filter:
* you may desire that a module is not started in certain conditions.
*/
static bool check(void) {
return true;
}

/*
* Should return not-0 value when module can be actually started (and thus polled).
* Use this to check intra-modules dependencies or any other env variable.
*
* Eg: you can evaluate your global state to make this module start right after
* certain conditions are met.
*/
static bool evaluate(void) {
return true;
}

/*
* Destroyer function, called at module unload (at end of program).
* Note that any module's fds are automatically closed for you.
*/
static void destroy(void) {

}

/*
* Default poll callback
*/
static void receive(const msg_t *msg, const void *userdata) {
if (msg->is_pubsub) {
switch (msg->ps_msg->type) {
Expand Down
35 changes: 1 addition & 34 deletions Samples/Cpp/pippo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,14 @@

static const self_t *doggo;

/*
* Declare and automagically initialize
* this module as soon as program starts.
*/
MODULE("Pippo");

static void receive_ready(const msg_t *msg, const void *userdata);

/*
* This function is automatically called before registering the module.
* Use this to set some global state needed eg: in check() function
*/
static void module_pre_start(void) {

}

/*
* Initializes this module's state;
* returns a valid fd to be polled.
*/
static void init(void) {
#ifdef __linux__
/* Add signal fd */
Expand All @@ -44,45 +32,24 @@ static void init(void) {
m_register_fd(fd, 1, NULL);
#endif

/* Add stdin fd */
/* Register stdin fd */
m_register_fd(STDIN_FILENO, 0, NULL);

m_ref("Doggo", &doggo);
}

/*
* Whether this module should be actually created:
* true if module must be created, !true otherwise.
*
* Use this function as a starting filter:
* you may desire that a module is not started in certain conditions.
*/
static bool check(void) {
return true;
}

/*
* Should return not-0 value when module can be actually started (and thus polled).
* Use this to check intra-modules dependencies or any other env variable.
*
* Eg: you can evaluate your global state to make this module start right after
* certain conditions are met.
*/
static bool evaluate(void) {
return true;
}

/*
* Destroyer function, called at module unload (at end of program).
* Note that module's FD is automatically closed for you.
*/
static void destroy(void) {

}

/*
* Default poll callback
*/
static void receive(const msg_t *msg, const void *userdata) {
if (!msg->is_pubsub) {
char c;
Expand Down
30 changes: 0 additions & 30 deletions Samples/Easy/doggo.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,24 @@ static void receive_sleeping(const msg_t *msg, const void *userdata);

static const self_t *new_mod;

/*
* Declare and automagically initialize
* this module as soon as program starts.
*/
MODULE("Doggo");

/*
* This function is automatically called before registering the module.
* Use this to set some global state needed eg: in check() function
*/
static void module_pre_start(void) {
printf("Press 'c' to start playing with your own doggo...\n");
}

/*
* Initializes this module's state;
* returns a valid fd to be polled.
*/
static void init(void) {

}

/*
* Whether this module should be actually created:
* true if module must be created, !true otherwise.
*
* Use this function as a starting filter:
* you may desire that a module is not started in certain conditions.
*/
static bool check(void) {
return true;
}

/*
* Should return not-0 value when module can be actually started (and thus polled).
* Use this to check intra-modules dependencies or any other env variable.
*
* Eg: you can evaluate your global state to make this module start right after
* certain conditions are met.
*/
static bool evaluate(void) {
return true;
}

/*
* Destroyer function, called at module unload (at end of program).
* Note that any module's fds are automatically closed for you.
*/
static void destroy(void) {

}
Expand Down
35 changes: 1 addition & 34 deletions Samples/Easy/pippo.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,16 @@

static const self_t *doggo;

/*
* Declare and automagically initialize
* this module as soon as program starts.
*/
MODULE("Pippo");

static int myData = 5;

static void receive_ready(const msg_t *msg, const void *userdata);

/*
* This function is automatically called before registering the module.
* Use this to set some global state needed eg: in check() function
*/
static void module_pre_start(void) {

}

/*
* Initializes this module's state;
* returns a valid fd to be polled.
*/
static void init(void) {
#ifdef __linux__
/* Add signal fd */
Expand All @@ -46,46 +34,25 @@ static void init(void) {
m_register_fd(fd, 1, &myData);
#endif

/* Add stdin fd */
/* Register stdin fd */
m_register_fd(STDIN_FILENO, 0, NULL);

/* Get Doggo module reference */
m_ref("Doggo", &doggo);
}

/*
* Whether this module should be actually created:
* true if module must be created, !true otherwise.
*
* Use this function as a starting filter:
* you may desire that a module is not started in certain conditions.
*/
static bool check(void) {
return true;
}

/*
* Should return not-0 value when module can be actually started (and thus polled).
* Use this to check intra-modules dependencies or any other env variable.
*
* Eg: you can evaluate your global state to make this module start right after
* certain conditions are met.
*/
static bool evaluate(void) {
return true;
}

/*
* Destroyer function, called at module unload (at end of program).
* Note that module's FD is automatically closed for you.
*/
static void destroy(void) {

}

/*
* Default poll callback
*/
static void receive(const msg_t *msg, const void *userdata) {
if (!msg->is_pubsub) {
char c;
Expand Down
38 changes: 1 addition & 37 deletions Samples/MultiCtx/a.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,15 @@
#include <string.h>

static const char *myCtx = "FirstCtx";
/*
* Declare and automagically initialize
* this module and its context as soon as program starts.
*/

MODULE_CTX("A", myCtx);

/*
* This function is automatically called before registering the module.
* Use this to set some global state needed eg: in check() function
*/
static void module_pre_start(void) {

}

static void receive_ready(const msg_t *msg, const void *userdata);

/*
* Initializes this module's state;
* returns a valid fd to be polled.
*/
static void init(void) {
#ifdef __linux__
int fd = timerfd_create(CLOCK_BOOTTIME, TFD_NONBLOCK);
Expand All @@ -41,39 +30,18 @@ static void init(void) {
#endif
}

/*
* Whether this module should be actually created:
* true if module must be created, !true otherwise.
*
* Use this function as a starting filter:
* you may desire that a module is not started in certain conditions.
*/
static bool check(void) {
return true;
}

/*
* Should return not-0 value when module can be actually started (and thus polled).
* Use this to check intra-modules dependencies or any other env variable.
*
* Eg: you can evaluate your global state to make this module start right after
* certain conditions are met.
*/
static bool evaluate(void) {
return true;
}

/*
* Destroyer function, called at module unload (at end of program).
* Note that module's FD is automatically closed for you.
*/
static void destroy(void) {

}

/*
* Default poll callback
*/
static void receive(const msg_t *msg, const void *userdata) {
if (!msg->is_pubsub) {
uint64_t t;
Expand All @@ -93,10 +61,6 @@ static void receive(const msg_t *msg, const void *userdata) {
}
}

/*
* Secondary poll callback.
* Use m_become(ready) to start using this second poll callback.
*/
static void receive_ready(const msg_t *msg, const void *userdata) {
if (!msg->is_pubsub) {
uint64_t t;
Expand Down

0 comments on commit 2d1f1da

Please sign in to comment.