1 /**************************************************************************/
2 /* ---------------------------------------------------------------------- */
3 /* Copyright (C) 2006 - 2008 FRESCOR consortium partners: */
5 /* Universidad de Cantabria, SPAIN */
6 /* University of York, UK */
7 /* Scuola Superiore Sant'Anna, ITALY */
8 /* Kaiserslautern University, GERMANY */
9 /* Univ. Politécnica Valencia, SPAIN */
10 /* Czech Technical University in Prague, CZECH REPUBLIC */
12 /* Thales Communication S.A. FRANCE */
13 /* Visual Tools S.A. SPAIN */
14 /* Rapita Systems Ltd UK */
17 /* See http://www.frescor.org for a link to partners' websites */
19 /* FRESCOR project (FP6/2005/IST/5-034026) is funded */
20 /* in part by the European Union Sixth Framework Programme */
21 /* The European Union is not liable of any use that may be */
22 /* made of this code. */
25 /* This file is part of FORB (Frescor Object Request Broker) */
27 /* FORB is free software; you can redistribute it and/or modify it */
28 /* under terms of the GNU General Public License as published by the */
29 /* Free Software Foundation; either version 2, or (at your option) any */
30 /* later version. FORB is distributed in the hope that it will be */
31 /* useful, but WITHOUT ANY WARRANTY; without even the implied warranty */
32 /* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
33 /* General Public License for more details. You should have received a */
34 /* copy of the GNU General Public License along with FORB; see file */
35 /* COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, */
36 /* Cambridge, MA 02139, USA. */
38 /* As a special exception, including FORB header files in a file, */
39 /* instantiating FORB generics or templates, or linking other files */
40 /* with FORB objects to produce an executable application, does not */
41 /* by itself cause the resulting executable application to be covered */
42 /* by the GNU General Public License. This exception does not */
43 /* however invalidate any other reasons why the executable file might be */
44 /* covered by the GNU Public License. */
45 /**************************************************************************/
52 * @author Michal Sojka <sojkam1@fel.cvut.cz>
53 * @date Sun Oct 12 15:50:30 2008
55 * @brief Data type and functions for manipulation with requests.
63 #include <forb/basic_types.h>
64 #include <forb/syncobj.h>
65 #include <ul_gavlcust.h>
66 #include <forb/forb-internal.h>
70 * Helper structure for sending ORB requests.
72 * Its purpose is to match incomming reply messages to previously sent
73 * requests. It is allocated in stub's stack and during waiting for
74 * reply is stored in forb_t::requests tree.
78 CORBA_unsigned_long request_id; /**< Numeric ID of this request. Used to match replies agains this request. */
79 FORB_CDR_Codec cdr_request; /**< Buffer for the request serialization. */
80 FORB_CDR_Codec *cdr_reply; /**< Buffer with received reply. */
81 gavl_node_t node; /**< forb_t::requests node */
82 forb_object obj; /**< Object being requested. */
83 unsigned method_ind; /**< Inddex of a method being requested. */
84 char *interface; /**< Interface being requested. */
85 struct forb_env *env; /**< Where to store exception returned in reply */
86 forb_syncobj_t reply_ready; /**< Synchronization object for waiting for reply */
87 forb_syncobj_t *reply_processed; /**< Synchronization object for receiver thread to wait for stub. */
90 typedef struct forb_request forb_request_t;
92 /* Declaration of AVL tree for storing sent requests. */
93 GAVL_CUST_NODE_INT_DEC(forb_request_nolock /* cust_prefix */,
94 forb_t /* cust_root_t */,
95 forb_request_t /* cust_item_t */,
96 CORBA_unsigned_long /* cust_key_t */,
97 requests /* cust_root_node */,
98 node /* cust_item_node */,
99 request_id /* cust_item_key */,
100 forb_request_cmp/* cust_cmp_fnc */);
103 forb_request_insert(forb_t *forb, forb_request_t *req)
106 fosa_mutex_lock(&forb->request_mutex);
107 ret = forb_request_nolock_insert(forb, req);
108 fosa_mutex_unlock(&forb->request_mutex);
113 forb_request_delete(forb_t *forb, forb_request_t *req)
115 fosa_mutex_lock(&forb->request_mutex);
116 forb_request_nolock_delete(forb, req);
117 fosa_mutex_unlock(&forb->request_mutex);
120 static inline forb_request_t *
121 forb_request_find(forb_t *forb, CORBA_unsigned_long *request_id)
124 fosa_mutex_lock(&forb->request_mutex);
125 ret = forb_request_nolock_find(forb, request_id);
126 fosa_mutex_unlock(&forb->request_mutex);
131 forb_request_init(forb_request_t *req, forb_object obj, char *iface, unsigned method_ind);
133 forb_request_destroy(forb_request_t *req);
135 forb_request_wait_for_reply(forb_request_t *req);
137 forb_request_signal_processed(forb_request_t *req);