CUBRID Engine  latest
wait_for_graph.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * wait_for_graph.h - Header file for WFG
22  *
23  */
24 
25 #ifndef _WAIT_FOR_GRAPH_H_
26 #define _WAIT_FOR_GRAPH_H_
27 
28 #ident "$Id$"
29 
30 #if defined(ENABLE_UNUSED_FUNCTION)
31 #include "thread_compat.hpp"
32 
33 typedef enum
34 {
35  WFG_CYCLE_YES_PRUNE, /* Cycles were found. There may be more not listed */
36  WFG_CYCLE_YES, /* Cycles were found. All the cycles are listed */
37  WFG_CYCLE_NO, /* There are not cycles */
38  WFG_CYCLE_ERROR /* An error was found during the cycle detection */
39 } WFG_CYCLE_CASE;
40 
41 /* structure of cycle which is obtained by wfg_detect_cycle() below */
42 typedef struct wfg_waiter WFG_WAITER;
43 struct wfg_waiter
44 {
45  int tran_index;
46  int (*cycle_fun) (int tran_index, void *args);
47  void *args; /* Arguments to be passed to cycle_fun */
48 };
49 
50 typedef struct wfg_listcycle WFG_CYCLE;
51 struct wfg_listcycle
52 {
53  int num_trans; /* # of transactions in the cycle */
54  WFG_WAITER *waiters; /* Waiters in the cycle */
55  struct wfg_listcycle *next; /* pointer to next cycle */
56 };
57 
58 extern int wfg_alloc_nodes (THREAD_ENTRY * thread_p, const int num_trans);
59 extern int wfg_free_nodes (THREAD_ENTRY * thread_p);
60 extern int wfg_insert_out_edges (THREAD_ENTRY * thread_p, const int wtran_index, int num_holders,
61  const int *htran_indices, int (*cycle_resolution_fn) (int tran_index, void *args),
62  void *args);
63 extern int wfg_remove_out_edges (THREAD_ENTRY * thread_p, const int waiter_tran_index, const int num_holders,
64  const int *htran_indices_p);
65 extern int wfg_get_status (int *num_edges_p, int *num_waiters_p);
66 extern int wfg_detect_cycle (THREAD_ENTRY * thread_p, WFG_CYCLE_CASE * cycle_case, WFG_CYCLE ** list_cycles_p);
67 extern int wfg_free_cycle (WFG_CYCLE * list_cycles_p);
68 extern int wfg_is_waiting (THREAD_ENTRY * thread_p, const int tran_index);
69 extern int wfg_get_tran_entries (THREAD_ENTRY * thread_p, const int tran_index);
70 
71 /* Transaction group interfaces */
72 extern int wfg_alloc_tran_group (THREAD_ENTRY * thread_p);
73 extern int wfg_insert_holder_tran_group (THREAD_ENTRY * thread_p, const int tran_group_index,
74  const int holder_tran_index);
75 extern int wfg_remove_holder_tran_group (THREAD_ENTRY * thread_p, const int tran_group_index,
76  const int holder_tran_index);
77 extern int wfg_insert_waiter_tran_group (THREAD_ENTRY * thread_p, const int tran_group_index,
78  const int waiter_tran_index, int (*cycle_resolution_fn) (int tran_index,
79  void *args),
80  void *args);
81 extern int wfg_remove_waiter_tran_group (THREAD_ENTRY * thread_p, const int tran_group_index,
82  const int waiter_tran_index);
83 extern int wfg_is_tran_group_waiting (THREAD_ENTRY * thread_p, const int tran_index);
84 
85 extern int wfg_dump (THREAD_ENTRY * thread_p);
86 #endif
87 #endif /* _WAIT_FOR_GRAPH_H_ */
void THREAD_ENTRY