implementation of daemon thread

hi,
I am new to thread mechanism so it may seem somewhat awkward.The scenario i am in is i want to fetch user input from main thread and simultaneously i want to run other threads in background.How do i achieve it.
Thanks.
Kushal
hi,

I recently started using Kahless_9 framework from www.shankodev.com due to work requirements. What I would do is something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class CParent;
class CUserInput : public KThreadProcessor
{
public:
   void Process()
   {
       // obtain user input in this method which runs in own thread
       // use your locally set members (m_pParent or whatever else)
       // to issue a thread from a pool to handle user input ...

      m_pParent->ProcessUserInput(ui);
   }

private:
    CParent     * m_pParent;
    ....
};


class CParent
{
public:

   void ProcessUserInput(UserInput ui)
   {
      // call for a free thread from the thread pool and process the user input
   }

private:
   KThreadPool     *  m_pThreadPool;
};

You really should let the main thread do UI stuff, and reserve other threads to process in the background.

You can run background threads with C++11 standard library.
http://en.cppreference.com/w/cpp/thread/thread
Topic archived. No new replies allowed.