picotm
0.6.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 void(* | picotm_module_validate_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_event_function) (const struct picotm_event *event, void *data, struct picotm_error *error) |
typedef void(* | picotm_module_undo_event_function) (const struct picotm_event *event, 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) |
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_event_function) (const struct picotm_event *event, void *data, struct picotm_error *error) |
Invoked by picotm during the commit phase to apply an event.
event | An event. | |
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 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_event_function) (const struct picotm_event *event, void *data, struct picotm_error *error) |
Invoked by picotm during the roll-back phase to revert an event.
event | An event. | |
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 void(* picotm_module_validate_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. |
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_validate_function | validate, | ||
picotm_module_apply_function | apply, | ||
picotm_module_undo_function | undo, | ||
picotm_module_apply_event_function | apply_event, | ||
picotm_module_undo_event_function | undo_event, | ||
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. | |
validate | The validate call-back function. | |
apply | The apply call-back function. | |
undo | The undo call-back function. | |
apply_event | The apply-event call-back function. | |
undo_event | The undo-event 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_rwlock * | conflicting_lock | ) |
Instructs the transaction management system to resolve a conflict between transactions.
conflicting_lock | The conflicting lock, or NULL if unknown. |