picotm
0.2.0
|
Picotm's module interface. More...
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "compiler.h"
#include "picotm-error.h"
Typedefs | |
typedef void(* | picotm_module_lock_function) (void *data, struct picotm_error *error) |
typedef void(* | picotm_module_unlock_function) (void *data, struct picotm_error *error) |
typedef bool(* | picotm_module_is_valid_function) (void *data, int is_irrevocable, struct picotm_error *error) |
typedef void(* | picotm_module_apply_function) (void *data, struct picotm_error *error) |
typedef void(* | picotm_module_undo_function) (void *data, struct picotm_error *error) |
typedef void(* | picotm_module_apply_events_function) (const struct picotm_event *events, size_t nevents, void *data, struct picotm_error *error) |
typedef void(* | picotm_module_undo_events_function) (const struct picotm_event *events, size_t nevents, void *data, struct picotm_error *error) |
typedef void(* | picotm_module_update_cc_function) (void *data, int is_irrevocable, struct picotm_error *error) |
typedef void(* | picotm_module_clear_cc_function) (void *data, int is_irrevocable, struct picotm_error *error) |
typedef void(* | picotm_module_finish_function) (void *data, struct picotm_error *error) |
typedef void(* | picotm_module_uninit_function) (void *data) |
typedef int(* | picotm_tabwalk_1_function) (void *data0) |
typedef int(* | picotm_tabwalk_2_function) (void *data0, void *data1) |
typedef int(* | picotm_tabwalk_3_function) (void *data0, void *data1, void *data2) |
typedef int(* | picotm_tab_compare_function) (const void *data0, const void *data1) |
Picotm is extensible. The header file picotm-module.h
contains the declaration of picotm's module interface. The interface allows for implementing support for additional features, libraries and functionality. All existing modules are written on top of this interface as well.
typedef void(* picotm_module_apply_events_function) (const struct picotm_event *events, size_t nevents, void *data, struct picotm_error *error) |
Invoked by picotm during the commit phase to apply a number of consecutive events.
events | An array of events. | |
nevents | The number of elements in events. | |
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_apply_function) (void *data, struct picotm_error *error) |
Invoked by picotm during the commit phase to apply changes of a module.
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_clear_cc_function) (void *data, int is_irrevocable, struct picotm_error *error) |
Invoked by picotm to clear a module's concurrency control during an abort.
data | The pointer to module-specific data. | |
is_irrevocable | True if the transaction is irrevocable, false otherwise. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_finish_function) (void *data, struct picotm_error *error) |
Invoked by picotm to clean up a module's resources at the end of a transaction.
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef bool(* picotm_module_is_valid_function) (void *data, int is_irrevocable, struct picotm_error *error) |
Invoked by picotm to validate a module's resources.
data | The pointer to module-specific data. | |
is_irrevocable | True if the transaction is irrevocable, false otherwise. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_lock_function) (void *data, struct picotm_error *error) |
Invoked by picotm to lock a module's resources at the beginning if a commit.
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_undo_events_function) (const struct picotm_event *events, size_t nevents, void *data, struct picotm_error *error) |
Invoked by picotm during the roll-back phase to revert a number of consecutive events.
events | An array of events. | |
nevents | The number of elements in events. | |
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_undo_function) (void *data, struct picotm_error *error) |
Invoked by picotm during the roll-back phase to revert changes of a module.
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_uninit_function) (void *data) |
Invoked by picotm to clean up a module's resources when the thread exists.
data | The pointer to module-specific data. |
typedef void(* picotm_module_unlock_function) (void *data, struct picotm_error *error) |
Invoked by picotm to unlock a module's resources. This is the inverse of picotm_module_lock_function.
data | The pointer to module-specific data. | |
[out] | error | Returns an error from the module. |
typedef void(* picotm_module_update_cc_function) (void *data, int is_irrevocable, struct picotm_error *error) |
Invoked by picotm to update a module's concurrency control during a commit.
data | The pointer to module-specific data. | |
is_irrevocable | True if the transaction is irrevocable, false otherwise. | |
[out] | error | Returns an error from the module. |
typedef int(* picotm_tab_compare_function) (const void *data0, const void *data1) |
Invoked by table functions for comparing two elements.
data0 | A table element. |
data1 | A table element. |
typedef int(* picotm_tabwalk_1_function) (void *data0) |
Invoked by table functions when walking over the elements of a table.
data0 | The table element. |
typedef int(* picotm_tabwalk_2_function) (void *data0, void *data1) |
Invoked by table functions when walking over the elements of a table.
data0 | The table element. |
data1 | An additional argument. |
typedef int(* picotm_tabwalk_3_function) (void *data0, void *data1, void *data2) |
Invoked by table functions when walking over the elements of a table.
data0 | The table element. |
data1 | An additional argument. |
data2 | An additional argument. |
PICOTM_NOTHROW void picotm_append_event | ( | unsigned long | module, |
unsigned long | op, | ||
uintptr_t | cookie, | ||
struct picotm_error * | error | ||
) |
Appends an event to the transaction's event log.
module | The module number | |
op | A module-specific operation. | |
cookie | A module-specific cookie. | |
[out] | error | Returns an error. |
PICOTM_NOTHROW void picotm_irrevocable | ( | void | ) |
Makes the current transaction irrevocable.
PICOTM_NOTHROW bool picotm_is_irrevocable | ( | void | ) |
Returns the transaction irrevocability status.
PICOTM_NOTHROW bool picotm_is_valid | ( | void | ) |
Validates the transaction state.
PICOTM_NOTHROW void picotm_recover_from_errno | ( | int | errno_hint | ) |
Instructs the transaction management system to recover from an error. The errno code is given as a hint.
errno_hint | The errno code of the detected error, or 0 if unknown. |
PICOTM_NOTHROW void picotm_recover_from_error | ( | const struct picotm_error * | error | ) |
Instructs the transaction management system to recover from an error. The error is supplied as an argument.
error | The detected error. |
PICOTM_NOTHROW void picotm_recover_from_error_code | ( | enum picotm_error_code | error_hint | ) |
Instructs the transaction management system to recover from an error. The error code is given as a hint.
error_hint | The error code of the detected error, or PICOTM_GENERAL_ERROR if unknown. |
PICOTM_NOTHROW unsigned long picotm_register_module | ( | picotm_module_lock_function | lock, |
picotm_module_unlock_function | unlock, | ||
picotm_module_is_valid_function | is_valid, | ||
picotm_module_apply_function | apply, | ||
picotm_module_undo_function | undo, | ||
picotm_module_apply_events_function | apply_events, | ||
picotm_module_undo_events_function | undo_events, | ||
picotm_module_update_cc_function | update_cc, | ||
picotm_module_clear_cc_function | clear_cc, | ||
picotm_module_finish_function | finish, | ||
picotm_module_uninit_function | uninit, | ||
void * | cbdata, | ||
struct picotm_error * | error | ||
) |
Registers a new module with the transaction management system.
lock | The lock call-back function. | |
unlock | The unlock call-back function. | |
is_valid | The is-valid call-back function. | |
apply | The apply call-back function. | |
undo | The undo call-back function. | |
apply_events | The apply-events call-back function. | |
undo_events | The undo-events call-back function. | |
update_cc | The update-CC call-back function. | |
clear_cc | The clear-CC call-back function. | |
finish | The finish call-back function. | |
uninit | The uninit call-back function. | |
cbdata | A pointer to module-specific data. | |
[out] | error | Returns an error. |
PICOTM_NOTHROW void picotm_resolve_conflict | ( | struct picotm_tx * | conflicting_tx | ) |
Instructs the transaction management system to resolve a conflict with another transaction.
conflicting_tx | The conflicting transaction, or NULL if unknown. |
PICOTM_NOTHROW void picotm_tabfree | ( | void * | base | ) |
Free table memory.
base | A pointer to the table's first element. |
PICOTM_NOTHROW void* picotm_tabresize | ( | void * | base, |
size_t | nelems, | ||
size_t | newnelems, | ||
size_t | siz | ||
) |
Allocate or resize table.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
newnelems | The new number of elements in the table. |
siz | The number of bytes per element. |
PICOTM_NOTHROW int picotm_tabrwalk_1 | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tabwalk_1_function | walk | ||
) |
Walk over table in reversed order.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
walk | The call-back function. |
PICOTM_NOTHROW int picotm_tabrwalk_2 | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tabwalk_2_function | walk, | ||
void * | data | ||
) |
Walk over table in reversed order.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
walk | The call-back function. |
data | An additional second argument to the call-back function. |
PICOTM_NOTHROW size_t picotm_tabuniq | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tab_compare_function | compare | ||
) |
Filters out duplicate elements
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
compare | The call-back function for comparing elements. |
PICOTM_NOTHROW int picotm_tabwalk_1 | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tabwalk_1_function | walk | ||
) |
Walk over table elements.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
walk | The call-back function. |
PICOTM_NOTHROW int picotm_tabwalk_2 | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tabwalk_2_function | walk, | ||
void * | data | ||
) |
Walk over table elements.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
walk | The call-back function. |
data | An additional second argument to the call-back function. |
PICOTM_NOTHROW int picotm_tabwalk_3 | ( | void * | base, |
size_t | nelems, | ||
size_t | siz, | ||
picotm_tabwalk_3_function | walk, | ||
void * | data1, | ||
void * | data2 | ||
) |
Walk over table elements.
base | A pointer to the table's first element. |
nelems | The number of elements in the table. |
siz | The number of bytes per element. |
walk | The call-back function. |
data1 | An additional second argument to the call-back function. |
data2 | An additional third argument to the call-back function. |