Commit d74e36e9 authored by Matthieu Dorier's avatar Matthieu Dorier

added completion functions

parent 2fc1c4b4
......@@ -32,6 +32,11 @@ LIBS="$SSG_LIBS $LIBS"
CPPFLAGS="$SSG_CFLAGS $CPPFLAGS"
CFLAGS="$SSG_CFLAGS $CFLAGS"
PKG_CHECK_MODULES([ARGOBOTS],[argobots],[],
AC_MSG_ERROR([Could not find working argobots installation!]) )
LIBS="$ARGOBOTS_LIBS $LIBS"
CPPFLAGS="$ARGOBOTS_CFLAGS $CPPFLAGS"
CFLAGS="$ARGOBOTS_CFLAGS $CFLAGS"
# checks for typedefs, structures, and compiler characteristics.
......
......@@ -131,7 +131,9 @@ typedef void *mobject_store_omap_iter_t;
* - Hints: mobject_store_write_op_set_alloc_hint()
* - Performing the operation: mobject_store_write_op_operate(), mobject_store_aio_write_op_operate()
*/
typedef void *mobject_store_write_op_t;
typedef struct mobject_store_write_op *mobject_store_write_op_t;
#define MOBJECT_WRITE_OP_NULL ((mobject_store_write_op_t)0)
/**
* @typedef mobject_store_read_op_t
......@@ -153,7 +155,9 @@ typedef void *mobject_store_write_op_t;
* - Performing the operation: mobject_store_read_op_operate(),
* mobject_store_aio_read_op_operate()
*/
typedef void *mobject_store_read_op_t;
typedef struct mobject_store_read_op *mobject_store_read_op_t;
#define MOBJECT_READ_OP_NULL ((void*)0)
/**
* @typedef mobject_store_completion_t
......@@ -161,7 +165,9 @@ typedef void *mobject_store_read_op_t;
* return value once the operation completes, and can be used to block
* until the operation is complete or safe.
*/
typedef void *mobject_store_completion_t;
typedef struct mobject_store_completion* mobject_store_completion_t;
#define MOBJECT_COMPLETION_NULL ((mobject_store_completion_t)0)
/*****************************************
* mobject store setup/teardown routines *
......
src_libmobject_store_la_SOURCES += \
src/libmobject-store.c \
src/completion.c src/completion.h \
src/log.h src/write-op.c src/write-op.h \
include/libmobject-store.h
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include <stdlib.h>
#include "mobject-store-config.h"
#include "libmobject-store.h"
#include "completion.h"
#include "log.h"
int mobject_store_aio_create_completion(void *cb_arg,
mobject_store_callback_t cb_complete,
mobject_store_callback_t cb_safe,
mobject_store_completion_t *pc)
{
int r;
mobject_store_completion_t completion =
(mobject_store_completion_t)calloc(1, sizeof(struct mobject_store_completion));
MOBJECT_ASSERT(completion != 0, "Could not allocate mobject_store_completion_t object");
completion->cb_complete = cb_complete;
completion->cb_safe = cb_safe;
completion->cb_arg = cb_arg;
r = ABT_eventual_create(sizeof(int), (void**)(&(completion->eventual)));
MOBJECT_ASSERT(r == ABT_SUCCESS, "Could not create ABT_eventual");
completion->ret_value_ptr = (int*)0;
r = ABT_rwlock_create(&(completion->lock));
MOBJECT_ASSERT(r == ABT_SUCCESS, "Could not create ABT_rwlock");
*pc = completion;
return 0;
}
int mobject_store_aio_wait_for_complete(mobject_store_completion_t c)
{
int r;
if(c == MOBJECT_COMPLETION_NULL) {
MOBJECT_LOG("Warning: passing NULL to mobject_store_aio_wait_for_complete");
return -1;
}
int* val_ptr = (int*)0;
r = ABT_eventual_wait(c->eventual, (void**)(&val_ptr));
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_eventual_wait failed");
r = ABT_rwlock_wrlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_wrlock failed");
c->ret_value_ptr = val_ptr;
r = ABT_rwlock_unlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_unlock failed");
return 0;
}
int mobject_store_aio_is_complete(mobject_store_completion_t c)
{
int r;
if(c == MOBJECT_COMPLETION_NULL) {
MOBJECT_LOG("Warning: passing NULL to mobject_store_aio_is_complete");
return 0;
}
int result = 0;
r = ABT_rwlock_rdlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_rdlock failed");
result = (c->ret_value_ptr != (int*)0);
r = ABT_rwlock_unlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_unlock failed");
return result;
}
int mobject_store_aio_get_return_value(mobject_store_completion_t c)
{
int r;
if(c == MOBJECT_COMPLETION_NULL) {
MOBJECT_LOG("Warning: passing NULL to mobject_store_aio_get_return_value");
return 0;
}
int result = 0;
r = ABT_rwlock_rdlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_rdlock failed");
if(c->ret_value_ptr != (int*)0) result = *(c->ret_value_ptr);
r = ABT_rwlock_unlock(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_unlock failed");
return 0;
}
void mobject_store_aio_release(mobject_store_completion_t c)
{
int r;
if(c == MOBJECT_COMPLETION_NULL) return;
r = ABT_eventual_free(c->eventual);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_eventual_free failed");
r = ABT_rwlock_free(c->lock);
MOBJECT_ASSERT(r == ABT_SUCCESS, "ABT_rwlock_free failed");
free(c);
}
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_COMPLETION_H
#define __MOBJECT_COMPLETION_H
#include <abt.h>
#include "mobject-store-config.h"
struct mobject_store_completion {
mobject_store_callback_t cb_complete; // completion callback
mobject_store_callback_t cb_safe; // safe callback
void* cb_arg; // arguments for callbacks
ABT_eventual eventual; // eventual used to notify completion
int* ret_value_ptr; // pointer to eventual's internal value
ABT_rwlock lock; // lock protecting access to this structure
};
#endif
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_LOG_H
#define __MOBJECT_LOG_H
#define STRINGIZE(x) STRINGIZE2(x)
#define STRINGIZE2(x) #x
#define LINE_STRING STRINGIZE(__LINE__)
#define MOBJECT_LOG(msg) do {\
fprintf(stderr,__FILE__ ":" LINE_STRING " " msg "\n");\
} while(0)
#define MOBJECT_ASSERT(cond, msg) if(!(cond)) {\
MOBJECT_LOG("assert (" #cond ") failed. " msg);\
exit(-1);\
}
#endif
/* src/mobject-store-config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#include <stdlib.h>
#include "mobject-store-config.h"
#include "libmobject-store.h"
#include "write-op.h"
#include "completion.h"
mobject_store_write_op_t mobject_store_create_write_op(void)
{
mobject_store_write_op_t write_op =
(mobject_store_write_op_t)calloc(1, sizeof(struct mobject_store_write_op));
// XXX assert result is valid
// TODO: set fields
return write_op;
}
void mobject_store_release_write_op(mobject_store_write_op_t write_op)
{
if(write_op == MOBJECT_WRITE_OP_NULL) return;
// TODO free internal fields
free(write_op);
}
void mobject_store_write_op_create(mobject_store_write_op_t write_op,
int exclusive,
const char* category)
{
}
void mobject_store_write_op_write(mobject_store_write_op_t write_op,
const char *buffer,
size_t len,
uint64_t offset)
{
}
void mobject_store_write_op_write_full(mobject_store_write_op_t write_op,
const char *buffer,
size_t len)
{
}
void mobject_store_write_op_writesame(mobject_store_write_op_t write_op,
const char *buffer,
size_t data_len,
size_t write_len,
uint64_t offset)
{
}
void mobject_store_write_op_append(mobject_store_write_op_t write_op,
const char *buffer,
size_t len)
{
}
void mobject_store_write_op_remove(mobject_store_write_op_t write_op)
{
}
void mobject_store_write_op_truncate(mobject_store_write_op_t write_op,
uint64_t offset)
{
}
void mobject_store_write_op_zero(mobject_store_write_op_t write_op,
uint64_t offset,
uint64_t len)
{
}
void mobject_store_write_op_omap_set(mobject_store_write_op_t write_op,
char const* const* keys,
char const* const* vals,
const size_t *lens,
size_t num)
{
}
void mobject_store_write_op_omap_rm_keys(mobject_store_write_op_t write_op,
char const* const* keys,
size_t keys_len)
{
}
int mobject_store_write_op_operate(mobject_store_write_op_t write_op,
mobject_store_ioctx_t io,
const char *oid,
time_t *mtime,
int flags)
{
}
int mobject_store_aio_write_op_operate(mobject_store_write_op_t write_op,
mobject_store_ioctx_t io,
mobject_store_completion_t completion,
const char *oid,
time_t *mtime,
int flags)
{
}
/*
* (C) 2017 The University of Chicago
*
* See COPYRIGHT in top-level directory.
*/
#ifndef __MOBJECT_WRITE_OP_H
#define __MOBJECT_WRITE_OP_H
#include "mobject-store-config.h"
struct mobject_store_write_op {
// TODO
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment