#include "server.h"
#include "sysdep_decls.h"
#include "msgbase.h"
-
+#include "threads.h"
/*
* define macros for module init stuff
*/
#define CTDL_INIT_CALL(module_name) ctdl_module_##module_name##_init (threading)
+#define CTDL_MODULE_UPGRADE(module_name) char *ctdl_module_##module_name##_upgrade (void)
+
+#define CTDL_UPGRADE_CALL(module_name) ctdl_module_##module_name##_upgrade ()
+
/*
* Prototype for making log entries in Citadel.
void CtdlRegisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
void CtdlUnregisterUserHook(void (*fcn_ptr)(struct ctdluser *), int EventType);
-void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
-void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *), int order);
+void CtdlRegisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
+void CtdlUnregisterXmsgHook(int (*fcn_ptr)(char *, char *, char *, char *), int order);
void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *),
int EventType);
* Citadel Threads API
*/
struct CtdlThreadNode *CtdlThreadCreate(char *name, long flags, void *(*thread_func) (void *arg), void *args);
+struct CtdlThreadNode *CtdlThreadSchedule(char *name, long flags, void *(*thread_func) (void *arg), void *args, time_t when);
void CtdlThreadSleep(int secs);
void CtdlThreadStop(struct CtdlThreadNode *thread);
-int CtdlThreadCheckStop(struct CtdlThreadNode *this_thread);
-void CtdlThreadCancel(struct CtdlThreadNode *thread);
-char *CtdlThreadName(struct CtdlThreadNode *thread, char *name);
+int CtdlThreadCheckStop(void);
+/* void CtdlThreadCancel2(struct CtdlThreadNode *thread); Leave this out, it should never be needed */
+const char *CtdlThreadName(const char *name);
struct CtdlThreadNode *CtdlThreadSelf(void);
int CtdlThreadGetCount(void);
int CtdlThreadGetWorkers(void);
+double CtdlThreadGetWorkerAvg(void);
+double CtdlThreadGetLoadAvg(void);
void CtdlThreadGC(void);
void CtdlThreadStopAll(void);
-int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, struct CtdlThreadNode *self);
+int CtdlThreadSelect(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+void CtdlThreadAllocTSD(void);
+
+#define CTDLTHREAD_BIGSTACK 0x0001
+#define CTDLTHREAD_WORKER 0x0002
/* Macros to speed up getting outr thread */
-#define CT _this_cit_thread
-#define CT_PUSH() \
- struct CtdlThreadNode *_this_cit_thread;\
- _this_cit_thread = CtdlThreadSelf()
+
+#define MYCURSORS (((ThreadTSD*)pthread_getspecific(ThreadKey))->cursors)
+#define MYTID (((ThreadTSD*)pthread_getspecific(ThreadKey))->tid)
+#define CT (((ThreadTSD*)pthread_getspecific(ThreadKey))->self)
+
#endif /* CTDL_MODULE_H */