mirror of
https://github.com/wassname/ray.git
synced 2026-07-28 11:25:04 +08:00
Run clang-format and check in Travis CI (#14)
* Run clang-format and add pre-commit hook for it. * Modify .travis.yml to check * Try to fix problems with .travis.yml * Try to fix .travis.yml yet again * Update .clang-format to Philipp's preferences * Don't allow lint to fail in Travis * Remove git-hooks directory * Improve clang-format failure output * Fix clang-format error * Report which commit clang-format is comparing against, and add whitespace error * Handle non-PR Travis in clang-format, and add another error * Check $TRAVIS_PULL_REQUEST correctly and add another error * Fix syntax error in check-git-clang-format-output.sh * Add whitespace error * Remove extra whitespace, add clang-format to README
This commit is contained in:
committed by
Robert Nishihara
parent
a62c0f8fac
commit
04737f3f56
+29
-17
@@ -3,8 +3,8 @@
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
UT_icd item_icd = { sizeof(event_loop_item), NULL, NULL, NULL };
|
||||
UT_icd poll_icd = { sizeof(struct pollfd), NULL, NULL, NULL };
|
||||
UT_icd item_icd = {sizeof(event_loop_item), NULL, NULL, NULL};
|
||||
UT_icd poll_icd = {sizeof(struct pollfd), NULL, NULL, NULL};
|
||||
|
||||
/* Initializes the event loop.
|
||||
* This function needs to be called before any other event loop function. */
|
||||
@@ -18,15 +18,19 @@ void event_loop_init(event_loop *loop) {
|
||||
* which can be queried using event_loop_type and event_loop_id. The parameter
|
||||
* events is the same as in http://linux.die.net/man/2/poll.
|
||||
* Returns the index of the item in the event loop. */
|
||||
int64_t event_loop_attach(event_loop *loop, int type, data_connection* connection, int fd, int events) {
|
||||
int64_t event_loop_attach(event_loop *loop,
|
||||
int type,
|
||||
data_connection *connection,
|
||||
int fd,
|
||||
int events) {
|
||||
assert(utarray_len(loop->items) == utarray_len(loop->waiting));
|
||||
int64_t index = utarray_len(loop->items);
|
||||
event_loop_item item = { .type = type };
|
||||
event_loop_item item = {.type = type};
|
||||
if (connection) {
|
||||
item.connection = *connection;
|
||||
}
|
||||
utarray_push_back(loop->items, &item );
|
||||
struct pollfd waiting = { .fd = fd, .events = events };
|
||||
utarray_push_back(loop->items, &item);
|
||||
struct pollfd waiting = {.fd = fd, .events = events};
|
||||
utarray_push_back(loop->waiting, &waiting);
|
||||
return index;
|
||||
}
|
||||
@@ -35,16 +39,18 @@ int64_t event_loop_attach(event_loop *loop, int type, data_connection* connectio
|
||||
* This invalidates all other indices into the event loop items, but leaves
|
||||
* the ids of the event loop items valid. */
|
||||
void event_loop_detach(event_loop *loop, int64_t index, int shall_close) {
|
||||
struct pollfd *waiting_item = (struct pollfd*) utarray_eltptr(loop->waiting, index);
|
||||
struct pollfd *waiting_back = (struct pollfd*) utarray_back(loop->waiting);
|
||||
struct pollfd *waiting_item =
|
||||
(struct pollfd *) utarray_eltptr(loop->waiting, index);
|
||||
struct pollfd *waiting_back = (struct pollfd *) utarray_back(loop->waiting);
|
||||
if (shall_close) {
|
||||
close(waiting_item->fd);
|
||||
}
|
||||
*waiting_item = *waiting_back;
|
||||
utarray_pop_back(loop->waiting);
|
||||
|
||||
event_loop_item *items_item = (event_loop_item*) utarray_eltptr(loop->items, index);
|
||||
event_loop_item *items_back = (event_loop_item*) utarray_back(loop->items);
|
||||
event_loop_item *items_item =
|
||||
(event_loop_item *) utarray_eltptr(loop->items, index);
|
||||
event_loop_item *items_back = (event_loop_item *) utarray_back(loop->items);
|
||||
*items_item = *items_back;
|
||||
utarray_pop_back(loop->items);
|
||||
}
|
||||
@@ -52,7 +58,8 @@ void event_loop_detach(event_loop *loop, int64_t index, int shall_close) {
|
||||
/* Poll the file descriptors associated to this event loop.
|
||||
* See http://linux.die.net/man/2/poll */
|
||||
int event_loop_poll(event_loop *loop) {
|
||||
return poll((struct pollfd*) utarray_front(loop->waiting), utarray_len(loop->waiting), -1);
|
||||
return poll((struct pollfd *) utarray_front(loop->waiting),
|
||||
utarray_len(loop->waiting), -1);
|
||||
}
|
||||
|
||||
/* Get the total number of file descriptors participating in the event loop. */
|
||||
@@ -60,20 +67,25 @@ int64_t event_loop_size(event_loop *loop) {
|
||||
return utarray_len(loop->waiting);
|
||||
}
|
||||
|
||||
/* Get the pollfd structure associated to a file descriptor participating in the event loop. */
|
||||
/* Get the pollfd structure associated to a file descriptor participating in the
|
||||
* event loop. */
|
||||
struct pollfd *event_loop_get(event_loop *loop, int64_t index) {
|
||||
return (struct pollfd*) utarray_eltptr(loop->waiting, index);
|
||||
return (struct pollfd *) utarray_eltptr(loop->waiting, index);
|
||||
}
|
||||
|
||||
/* Set the data connection information for participant in the event loop. */
|
||||
void event_loop_set_connection(event_loop *loop, int64_t index, const data_connection* conn) {
|
||||
event_loop_item *item = (event_loop_item*) utarray_eltptr(loop->items, index);
|
||||
void event_loop_set_connection(event_loop *loop,
|
||||
int64_t index,
|
||||
const data_connection *conn) {
|
||||
event_loop_item *item =
|
||||
(event_loop_item *) utarray_eltptr(loop->items, index);
|
||||
item->connection = *conn;
|
||||
}
|
||||
|
||||
/* Get the data connection information for participant in the event loop. */
|
||||
data_connection* event_loop_get_connection(event_loop *loop, int64_t index) {
|
||||
event_loop_item *item = (event_loop_item*) utarray_eltptr(loop->items, index);
|
||||
data_connection *event_loop_get_connection(event_loop *loop, int64_t index) {
|
||||
event_loop_item *item =
|
||||
(event_loop_item *) utarray_eltptr(loop->items, index);
|
||||
return &item->connection;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user