Simple threading support for PG+ talkers. Tested on AMI Linux (RHEL). YMMV.
A functioning Playground Plus talk server.
NOTE: These instructions require more testing with out-of-the-box PG+.
-
Add
src/threads.cprovided in this repo to your talker'ssrcdirectory. -
Add
src/threads-example.cprovided in this repo to your talker'ssrcdirectory. This contains an example of a command that takes advantage of threads. -
Replace
src/configure/Configure.helpwith the one provided in this repo (or add the help items for THREADS and MAX_THREADS at the end). -
Update
src/configure/Configure.optionsby inserting the following code at ~line 35:# comment 'Threaded commands' bool 'Allow development of threaded commands' THREADS if [ "$THREADS" = "y" ]; then int ' Max threads' MAX_THREADS fi -
Update
src/include/proto.hby inserting the following code at ~line 380:#ifdef THREADS extern void threads_version(void); #endif /* THREADS */ -
Update
src/include/proto.hby inserting the following code at ~line 498:#ifdef THREADS struct thread_task { int status; player *p; char cmd[512]; char ret[2048]; int (*report)(struct thread_task*); }; #endif /* THREADS */ -
Update
src/version.cby inserting the following code at ~line 161:#ifdef THREADS threads_version(); #endif /* THREADS */ -
Update
src/glue.cby inserting the following code at ~line 269:#ifdef THREADS #include "threads.c" #endif /* THREADS */
During make config, set the MAX_THREADS option as you see fit. You shouldn't need more than 4-8 unless you're really going crazy with threading.
- Recompile using the standard PG+ compilation process.