19 #include "threadserver.h"
20 #include "threadexceptions.h"
28 const std::string thread1=
"thread_1";
32 const std::string thread2=
"thread_2";
37 const std::string thread3=
"invalid_thread";
45 void *my_thread_function1(
void *param)
51 std::cout <<
"thread 1 loop " << i << std::endl;
64 void *my_thread_function2(
void *param)
70 std::cout <<
"thread 2 loop " << i << std::endl;
141 int main(
int argc,
char *argv[])
150 thread_server->
attach_thread(thread1,my_thread_function1,NULL);
151 thread_server->
attach_thread(thread2,my_thread_function2,NULL);
163 std::cout << e.
what() << std::endl;
170 thread_server->
attach_thread(thread3,my_thread_function2,NULL);
172 std::cout << e.
what() << std::endl;
Thread server exception class.
void create_thread(const std::string &thread_id)
Function to create a new thread.
void start_thread(const std::string &thread_id)
Function to start a thread.
virtual const std::string & what(void)
Function to get the error message.
void kill_thread(const std::string &thread_id)
Function to immediately terminate a thread.
void end_thread(const std::string &thread_id)
Function to request the termination of a thread.
void delete_thread(const std::string &thread_id)
Function to delete an existing thread.
void attach_thread(const std::string &thread_id, void *(*user_thread_function)(void *param), void *param)
Function to attach a function to a thread.
void detach_thread(const std::string &thread_id)
Function to detach a function from a thread.
static CThreadServer * instance(void)
Function to get a reference to the unique instance.