1 #ifndef _XBT_CONTEXT_PRIVATE_H
2 #define _XBT_CONTEXT_PRIVATE_H
4 #include "xbt/sysdep.h"
5 #include "xbt/context.h"
10 /* *********************** */
11 /* Context type definition */
12 /* *********************** */
13 /* the following function pointers describe the interface that all context concepts must implement */
14 typedef void (*xbt_pfn_context_free_t) (xbt_context_t); /* pointer type to the function used to destroy the specified context */
15 typedef void (*xbt_pfn_context_kill_t) (xbt_context_t); /* pointer type to the function used to kill the specified context */
16 typedef void (*xbt_pfn_context_schedule_t) (xbt_context_t); /* pointer type to the function used to resume the specified context */
17 typedef void (*xbt_pfn_context_yield_t) (void); /* pointer type to the function used to yield the specified context */
18 typedef void (*xbt_pfn_context_start_t) (xbt_context_t); /* pointer type to the function used to start the specified context */
19 typedef void (*xbt_pfn_context_stop_t) (int); /* pointer type to the function used to stop the current context */
21 /* each context type must contain this macro at its begining -- OOP in C :/ */
22 #define XBT_CTX_BASE_T \
23 s_xbt_swag_hookup_t hookup; \
25 void_f_pvoid_t cleanup_func; \
27 ex_ctx_t *exception; \
29 xbt_main_func_t code; \
32 void_f_pvoid_t startup_func; \
34 xbt_pfn_context_free_t free; \
35 xbt_pfn_context_kill_t kill; \
36 xbt_pfn_context_schedule_t schedule; \
37 xbt_pfn_context_yield_t yield; \
38 xbt_pfn_context_start_t start; \
39 xbt_pfn_context_stop_t stop
41 /* all other context types derive from this structure */
42 typedef struct s_xbt_context {
46 /* ****************** */
47 /* Globals definition */
48 /* ****************** */
51 extern xbt_context_t current_context;
52 extern xbt_context_t maestro_context;
55 extern xbt_swag_t context_living;
56 extern xbt_swag_t context_to_destroy;
58 /* *********************** */
59 /* factory type definition */
60 /* *********************** */
61 typedef struct s_xbt_context_factory *xbt_context_factory_t;
63 /* this function describes the interface that all context factory must implement */
64 typedef xbt_context_t(*xbt_pfn_context_factory_create_context_t) (const
75 int (*xbt_pfn_context_factory_create_maestro_context_t) (xbt_context_t
78 /* this function finalize the specified context factory */
79 typedef int (*xbt_pfn_context_factory_finalize_t) (xbt_context_factory_t
82 /* this interface is used by the xbt context module to create the appropriate concept */
83 typedef struct s_xbt_context_factory {
84 xbt_pfn_context_factory_create_maestro_context_t create_maestro_context; /* create the context of the maestro */
85 xbt_pfn_context_factory_create_context_t create_context; /* create a new context */
86 xbt_pfn_context_factory_finalize_t finalize; /* finalize the context factory */
87 const char *name; /* the name of the context factory */
89 } s_xbt_context_factory_t;
92 * This function select a context factory associated with the name specified by
94 * If successful the function returns 0. Otherwise the function returns the error
98 xbt_context_select_factory(const char *name);
101 * This function initialize a context factory from the name specified by the parameter
103 * If the factory cannot be found, an exception is raised.
107 xbt_context_init_factory_by_name(xbt_context_factory_t * factory,
111 /* All factories init */
112 void xbt_ctx_thread_factory_init(xbt_context_factory_t * factory);
113 void xbt_ctx_sysv_factory_init(xbt_context_factory_t * factory);
114 void xbt_ctx_java_factory_init(xbt_context_factory_t * factory);
121 #endif /* !_XBT_CONTEXT_PRIVATE_H */