mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Allow arbitrary number of connections (#13)
* refactor plasma to use an event loop * unify comment style * Clean up Makefile flags. * Randomize socket names in tests so multiple copies of the tests can be run in parallel without conflict.
This commit is contained in:
committed by
Robert Nishihara
parent
dd23a68f79
commit
a62c0f8fac
@@ -0,0 +1,36 @@
|
||||
#ifndef EVENT_LOOP_H
|
||||
#define EVENT_LOOP_H
|
||||
|
||||
#include <poll.h>
|
||||
|
||||
#include "utarray.h"
|
||||
#include "plasma.h"
|
||||
#include "plasma_manager.h"
|
||||
|
||||
typedef struct {
|
||||
/* The type of connection (e.g. redis, client, manager, data transfer). */
|
||||
int type;
|
||||
/* If type is data transfer, this contains information about the status
|
||||
* of the transfer. */
|
||||
data_connection connection;
|
||||
} event_loop_item;
|
||||
|
||||
typedef struct {
|
||||
/* Array of event_loop_items that hold information for connections. */
|
||||
UT_array *items;
|
||||
/* Array of file descriptors that are waiting, corresponding to items. */
|
||||
UT_array *waiting;
|
||||
} event_loop;
|
||||
|
||||
/* Event loop functions. */
|
||||
void event_loop_init(event_loop *loop);
|
||||
void event_loop_free(event_loop *loop);
|
||||
int64_t event_loop_attach(event_loop *loop, int type, data_connection* connection, int fd, int events);
|
||||
void event_loop_detach(event_loop *loop, int64_t index, int shall_close);
|
||||
int event_loop_poll(event_loop *loop);
|
||||
int64_t event_loop_size(event_loop *loop);
|
||||
struct pollfd *event_loop_get(event_loop *loop, int64_t index);
|
||||
void event_loop_set_connection(event_loop *loop, int64_t index, const data_connection* conn);
|
||||
data_connection *event_loop_get_connection(event_loop *loop, int64_t index);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user