1 #ifndef _XBT_CONTEXT_PRIVATE_H
\r
2 #define _XBT_CONTEXT_PRIVATE_H
\r
4 #include "xbt/sysdep.h"
\r
5 #include "xbt/context.h"
\r
6 #include "xbt/swag.h"
\r
10 /* *********************** */
\r
11 /* Context type definition */
\r
12 /* *********************** */
\r
14 /* the following function pointers describe the interface that all context concepts must implement */
\r
15 typedef void (*xbt_pfn_context_free_t)(xbt_context_t); /* pointer type to the function used to destroy the specified context */
\r
16 typedef void (*xbt_pfn_context_kill_t)(xbt_context_t); /* pointer type to the function used to kill the specified context */
\r
17 typedef void (*xbt_pfn_context_schedule_t)(xbt_context_t); /* pointer type to the function used to resume the specified context */
\r
18 typedef void (*xbt_pfn_context_yield_t)(void); /* pointer type to the function used to yield the specified context */
\r
19 typedef void (*xbt_pfn_context_start_t)(xbt_context_t); /* pointer type to the function used to start the specified context */
\r
20 typedef void (*xbt_pfn_context_stop_t)(int); /* pointer type to the function used to stop the current context */
\r
22 /* each context type must contain this macro at its begining -- OOP in C :/ */
\r
23 #define XBT_CTX_BASE_T \
\r
24 s_xbt_swag_hookup_t hookup; \
\r
26 void_f_pvoid_t cleanup_func; \
\r
27 void *cleanup_arg; \
\r
28 ex_ctx_t *exception; \
\r
30 xbt_main_func_t code; \
\r
33 void_f_pvoid_t startup_func; \
\r
34 void *startup_arg; \
\r
35 xbt_pfn_context_free_t free; \
\r
36 xbt_pfn_context_kill_t kill; \
\r
37 xbt_pfn_context_schedule_t schedule; \
\r
38 xbt_pfn_context_yield_t yield; \
\r
39 xbt_pfn_context_start_t start; \
\r
40 xbt_pfn_context_stop_t stop
\r
42 /* all other context types derive from this structure */
\r
43 typedef struct s_xbt_context {
\r
47 /* ****************** */
\r
48 /* Globals definition */
\r
49 /* ****************** */
\r
51 /* Important guys */
\r
52 extern xbt_context_t current_context;
\r
53 extern xbt_context_t maestro_context;
\r
54 /* All dudes lists */
\r
55 extern xbt_swag_t context_living;
\r
56 extern xbt_swag_t context_to_destroy;
\r
58 /* *********************** */
\r
59 /* factory type definition */
\r
60 /* *********************** */
\r
61 typedef struct s_xbt_context_factory * xbt_context_factory_t;
\r
63 /* this function describes the interface that all context factory must implement */
\r
64 typedef xbt_context_t (*xbt_pfn_context_factory_create_context_t)(const char*, xbt_main_func_t, void_f_pvoid_t, void*, void_f_pvoid_t, void*, int, char**);
\r
65 typedef int (*xbt_pfn_context_factory_create_maestro_context_t)(xbt_context_t*);
\r
67 /* this function finalize the specified context factory */
\r
68 typedef int (*xbt_pfn_context_factory_finalize_t)(xbt_context_factory_t*);
\r
70 /* this interface is used by the xbt context module to create the appropriate concept */
\r
71 typedef struct s_xbt_context_factory {
\r
72 xbt_pfn_context_factory_create_maestro_context_t create_maestro_context; /* create the context of the maestro */
\r
73 xbt_pfn_context_factory_create_context_t create_context; /* create a new context */
\r
74 xbt_pfn_context_factory_finalize_t finalize; /* finalize the context factory */
\r
75 const char* name; /* the name of the context factory */
\r
77 } s_xbt_context_factory_t;
\r
80 * This function select a context factory associated with the name specified by
\r
81 * the parameter name.
\r
82 * If successful the function returns 0. Otherwise the function returns the error
\r
86 xbt_context_select_factory(const char* name);
\r
89 * This function initialize a context factory from the name specified by the parameter
\r
91 * If the factory cannot be found, an exception is raised.
\r
94 xbt_context_init_factory_by_name(xbt_context_factory_t* factory, const char* name);
\r
97 /* All factories init */
\r
98 void xbt_ctx_thread_factory_init(xbt_context_factory_t* factory);
\r
99 void xbt_ctx_sysv_factory_init(xbt_context_factory_t* factory);
\r
100 void xbt_ctx_java_factory_init(xbt_context_factory_t* factory);
\r
108 #endif /* !_XBT_CONTEXT_PRIVATE_H */
\r