ray/src/plasma.h

81 lines
2 KiB
C
Raw Normal View History

2016-08-13 17:11:11 -07:00
#ifndef PLASMA_H
#define PLASMA_H
#include <inttypes.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
2016-08-17 12:54:34 -07:00
#ifdef NDEBUG
#define LOG_DEBUG(M, ...)
#else
#define LOG_DEBUG(M, ...) \
fprintf(stderr, "[DEBUG] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#endif
2016-08-13 17:11:11 -07:00
#define LOG_ERR(M, ...) \
fprintf(stderr, "[ERROR] (%s:%d: errno: %s) " M "\n", \
__FILE__, __LINE__, errno == 0 ? "None" : strerror(errno), ##__VA_ARGS__)
#define LOG_INFO(M, ...) \
fprintf(stderr, "[INFO] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__)
typedef struct {
int64_t size;
int64_t create_time;
int64_t construct_duration;
} plasma_object_info;
// Represents an object id hash, can hold a full SHA1 hash
typedef struct {
unsigned char id[20];
} plasma_id;
2016-08-17 12:54:34 -07:00
// these values must be in sync with the ones in plasma.py (can we have a test for that?)
2016-08-13 17:11:11 -07:00
enum plasma_request_type {
PLASMA_CREATE, // create a new object
PLASMA_GET, // get an object
2016-08-15 16:41:22 -07:00
PLASMA_SEAL, // seal an object
PLASMA_TRANSFER, // request transfer to another store
PLASMA_DATA, // header for sending data
2016-08-13 17:11:11 -07:00
};
typedef struct {
int type;
plasma_id object_id;
int64_t size;
2016-08-15 16:41:22 -07:00
uint8_t addr[4];
int port;
2016-08-13 17:11:11 -07:00
} plasma_request;
enum plasma_reply_type {
PLASMA_OBJECT, // the file descriptor represents an object
PLASMA_FUTURE, // the file descriptor represents a future
};
typedef struct {
int type;
int64_t size;
} plasma_reply;
typedef struct {
plasma_id object_id;
void *data;
int64_t size;
int writable;
} plasma_buffer;
// Connect to the local plasma store UNIX domain socket
2016-08-13 17:11:11 -07:00
int plasma_store_connect(const char* socket_name);
// Connect to a possibly remote plasma manager
int plasma_manager_connect(const char* addr, int port);
void plasma_create(int store, plasma_id object_id, int64_t size, void **data);
void plasma_get(int store, plasma_id object_id, int64_t *size, void **data);
void plasma_seal(int store, plasma_id object_id);
void plasma_send(int conn, plasma_request *req);
2016-08-17 12:54:34 -07:00
2016-08-13 17:11:11 -07:00
#endif