1 /**************************************************************************/
2 /* Copyright (C) 2010 Czech Technical University in Prague */
4 /* This file is part of FRSH (FRescor ScHeduler) */
6 /* FRSH is free software; you can redistribute it and/or modify it */
7 /* under terms of the GNU General Public License as published by the */
8 /* Free Software Foundation; either version 2, or (at your option) any */
9 /* later version. FRSH is distributed in the hope that it will be */
10 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
11 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
12 /* General Public License for more details. You should have received a */
13 /* copy of the GNU General Public License along with FRSH; see file */
14 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
15 /* Cambridge, MA 02139, USA. */
17 /* As a special exception, including FRSH header files in a file, */
18 /* instantiating FRSH generics or templates, or linking other files */
19 /* with FRSH objects to produce an executable application, does not */
20 /* by itself cause the resulting executable application to be covered */
21 /* by the GNU General Public License. This exception does not */
22 /* however invalidate any other reasons why the executable file might be */
23 /* covered by the GNU Public License. */
24 /**************************************************************************/
27 #ifndef _FRSH_TRANSACTION_H_
28 #define _FRSH_TRANSACTION_H_
30 #include "frsh_cpp_macros.h"
31 #include "frsh_core_types.h"
35 struct fres_transaction_t_type;
37 /* frsh_transaction_t is a pointer to resemble how frsh_contract_t is
39 typedef struct fres_transaction_t_type *frsh_transaction_t;
42 * Initialize a transaction.
46 * @param name The name of the transaction which can be used in
47 * frsh_transaction_wait_for_name().
49 * @return Zero on success, non-zero error code on return.
52 frsh_transaction_init(frsh_transaction_t *transaction,
56 * Deallocates memory of the transaction object.
61 frsh_transaction_destroy(frsh_transaction_t *transaction);
64 * Add a contract to the transaction.
66 * @param transaction Transaction
67 * @param contract Contract to add
69 * @param index Index of the contract within the transaction. The
70 * index is used in frsh_transaction_alloc_vres(). The first added
71 * contract must have zero index, the second one, etc.
73 * @return Zero on success, non-zero error code on return.
76 frsh_transaction_add_contract(frsh_transaction_t *transaction,
77 frsh_contract_t *contract,
81 * Negotiates a multi-resource transaction.
83 * No resource is allocated in this step of negotiation. Use
84 * frsh_transaction_alloc_vres() to allocate resource and use it in
87 * @param trans Transaction with added contracts.
89 * @return Zero on success, non-zero error code on return.
92 frsh_transaction_negotiate(frsh_transaction_t *trans);
95 * Cancels a negotiated transaction.
99 * @return Zero on success, non-zero error code on return.
102 frsh_transaction_cancel(frsh_transaction_t *trans);
105 * Retrieves a negotiated transaction by name.
107 * Applications that do not initiate transaction negotiation need a
108 * way to participate in the transaction. This function waits until
109 * the transaction with a given @a name is negotiated and then returns
110 * the @a transaction object.
115 * @return Zero on success, non-zero error code on return.
118 frsh_transaction_wait_for_name(frsh_transaction_t *transaction,
121 * Allocates VRES from the negotiated transaction.
123 * Given the transaction object and an index (see
124 * frsh_transaction_add_contract()) this function requests allocation
134 frsh_transaction_alloc_vres(frsh_transaction_t *t,
136 frsh_vres_id_t *vres);
140 #endif // _FRSH_TRANSACTION_H_