\r
SG_BEGIN_DECL()\r
\r
+/* *********************** */\r
+/* Context type definition */\r
+/* *********************** */\r
+ \r
/* the following function pointers describe the interface that all context concepts must implement */\r
-\r
typedef void (*xbt_pfn_context_free_t)(xbt_context_t); /* pointer type to the function used to destroy the specified context */\r
typedef void (*xbt_pfn_context_kill_t)(xbt_context_t); /* pointer type to the function used to kill the specified context */\r
typedef void (*xbt_pfn_context_schedule_t)(xbt_context_t); /* pointer type to the function used to resume the specified context */\r
-typedef void (*xbt_pfn_context_yield_t)(void); /* pointer type to the function used to yield the specified context */\r
+typedef void (*xbt_pfn_context_yield_t)(void); /* pointer type to the function used to yield the specified context */\r
typedef void (*xbt_pfn_context_start_t)(xbt_context_t); /* pointer type to the function used to start the specified context */\r
-typedef void (*xbt_pfn_context_stop_t)(int); /* pointer type to the function used to stop the current context */\r
+typedef void (*xbt_pfn_context_stop_t)(int); /* pointer type to the function used to stop the current context */\r
\r
-/* each context concept must use this macro in its declaration */\r
+/* each context type must contain this macro at its begining -- OOP in C :/ */\r
#define XBT_CTX_BASE_T \\r
s_xbt_swag_hookup_t hookup; \\r
char *name; \\r
xbt_pfn_context_start_t start; \\r
xbt_pfn_context_stop_t stop \r
\r
-/* all other contexts derive from this structure */\r
-typedef struct s_xbt_context\r
-{\r
+/* all other context types derive from this structure */\r
+typedef struct s_xbt_context {\r
XBT_CTX_BASE_T;\r
-}s_xbt_context_t;\r
+} s_xbt_context_t;\r
+\r
+/* ****************** */\r
+/* Globals definition */\r
+/* ****************** */\r
\r
/* Important guys */\r
extern xbt_context_t current_context;\r
extern xbt_swag_t context_living;\r
extern xbt_swag_t context_to_destroy;\r
\r
+/* *********************** */\r
+/* factory type definition */\r
+/* *********************** */\r
+typedef struct s_xbt_context_factory * xbt_context_factory_t;\r
+\r
+/* this function describes the interface that all context factory must implement */\r
+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
+typedef int (*xbt_pfn_context_factory_create_maestro_context_t)(xbt_context_t*);\r
+\r
+/* this function finalize the specified context factory */\r
+typedef int (*xbt_pfn_context_factory_finalize_t)(xbt_context_factory_t*);\r
+\r
+/* this interface is used by the xbt context module to create the appropriate concept */\r
+typedef struct s_xbt_context_factory {\r
+ xbt_pfn_context_factory_create_maestro_context_t create_maestro_context; /* create the context of the maestro */\r
+ xbt_pfn_context_factory_create_context_t create_context; /* create a new context */\r
+ xbt_pfn_context_factory_finalize_t finalize; /* finalize the context factory */\r
+ const char* name; /* the name of the context factory */\r
+ \r
+} s_xbt_context_factory_t;\r
+\r
+/**\r
+ * This function select a context factory associated with the name specified by\r
+ * the parameter name.\r
+ * If successful the function returns 0. Otherwise the function returns the error\r
+ * code.\r
+ */\r
+int\r
+xbt_context_select_factory(const char* name);\r
+\r
+/**\r
+ * This function initialize a context factory from the name specified by the parameter\r
+ * name.\r
+ * If the factory cannot be found, an exception is raised.\r
+ */\r
+void\r
+xbt_context_init_factory_by_name(xbt_context_factory_t* factory, const char* name);\r
+\r
\r
/* All factories init */\r
-typedef struct s_xbt_context_factory* xbt_context_factory_t;\r
+void xbt_ctx_thread_factory_init(xbt_context_factory_t* factory);\r
+void xbt_ctx_sysv_factory_init(xbt_context_factory_t* factory);\r
+void xbt_ctx_java_factory_init(xbt_context_factory_t* factory);\r
+\r
+\r
\r
-int xbt_thread_context_factory_init(xbt_context_factory_t* factory);\r
-int xbt_ucontext_factory_init(xbt_context_factory_t* factory);\r
-int xbt_jcontext_factory_init(xbt_context_factory_t* factory);\r
\r
\r
SG_END_DECL()\r