4 * @brief Interface of dispatcher_t.
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 #include "controller.h"
28 typedef struct dispatcher_t dispatcher_t
;
31 * @brief Dispatcher, accepts connections using multiple threads.
33 * The dispatcher creates a session for each client (using SID cookies). In
34 * each session, a session context is created using the context constructor.
35 * Each controller is instanciated in the session using the controller
36 * constructor added with add_controller.
41 * @brief Register a controller to the dispatcher.
43 * The first controller added serves as default controller. Client's
44 * get redirected to it if no other controller matches.
46 * @param constructor constructor function to the conntroller
47 * @param param param to pass to constructor
49 void (*add_controller
)(dispatcher_t
*this,
50 controller_constructor_t constructor
, void *param
);
53 * @brief Start with dispatching.
55 * It may be necessary to call per-thread initialization functions.
56 * If init is not NULL, the handler is called right after thread
57 * creation (by the created thread) and the deinit function is called
58 * before the thread gets destroyed (again by the thread itself).
60 * @param thread number of dispatching threads
61 * @param init thread specific initialization function, or NULL
62 * @param init_param param to pass to init function
63 * @param deinit thread dpecific deinitialization function, or NULL
64 * @param deinit_param param to pass to deinit function
66 void (*run
)(dispatcher_t
*this, int threads
,
67 void(*init
)(void *param
), void *init_param
,
68 void(*deinit
)(void *param
), void *deinit_param
);
71 * @brief Wait for a relevant signal action.
73 void (*waitsignal
)(dispatcher_t
*this);
76 * @brief Destroy the dispatcher_t.
78 void (*destroy
) (dispatcher_t
*this);
82 * @brief Create a dispatcher.
84 * The context constructor is invoked to create a session context for
87 * @param socket FastCGI socket path, NULL for dynamic
88 * @param timeout session timeout
89 * @param constructor construction function for session context
90 * @param param parameter to supply to context constructor
92 dispatcher_t
*dispatcher_create(char *socket
, int timeout
,
93 context_constructor_t constructor
, void *param
);
95 #endif /* DISPATCHER_H_ */