/[LeafOK_CVS]/innwebd/base.cpp
ViewVC logotype

Diff of /innwebd/base.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.3 by sysadm, Sat Jul 3 15:10:23 2004 UTC Revision 1.4 by sysadm, Sun Jul 4 06:45:23 2004 UTC
# Line 1  Line 1 
1  /*******************************************************/  /*******************************************************/
2  /*                                                     */  /*                                                     */
3  /*  LeafOK Innd                                        */  /*  LeafOK Innbbsd                                     */
4  /*  Copyright (C) LeafOK.com, 2003-2004                */  /*  Copyright (C) LeafOK.com, 2003-2004                */
5  /*                                                     */  /*                                                     */
6  /*  Programmed by Leaf                                 */  /*  Programmed by Leaf                                 */
7  /*  E-mail:leaf@leafok.com  QQ:6049044                 */  /*  E-mail:leaflet@leafok.com  QQ:6049044              */
8  /*                                                     */  /*                                                     */
9  /*  http://bbs.leafok.com                              */  /*  http://bbs.leafok.com                              */
10  /*  http://bbs.leafok.net                              */  /*  http://bbs.leafok.net                              */
# Line 22  using namespace std; Line 22  using namespace std;
22    
23  base::base(void)  base::base(void)
24  : p_ParentThread(NULL)  : p_ParentThread(NULL)
25    , p_ThreadPool(NULL)
26    , ulMainThreadId(0)
27  , innd_uid(0)  , innd_uid(0)
28  , isConnected(false)  , isConnected(false)
29  , running(false)  , running(false)
# Line 30  base::base(void) Line 32  base::base(void)
32    
33  base::~base(void)  base::~base(void)
34  {  {
35            if (this->GetThreadPool() != NULL)
36                    delete (this->GetThreadPool());
37  }  }
38    
39  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)
# Line 489  int base::begin(void) Line 493  int base::begin(void)
493    
494  DWORD base::Thread(LPVOID pParam)  DWORD base::Thread(LPVOID pParam)
495  {  {
         HANDLE hThreadCurrent;  
496          base* p;          base* p;
497    
498          syslog << logfile::log_head << "Thread started." << endl;          syslog << logfile::log_head << "Thread started." << endl;
499    
500          p = (base*)pParam;          p = (base*)pParam;
         hThreadCurrent = GetCurrentThread();  
501    
502          if (p->GetParentThread()->GetThreadPool()->AddThread(hThreadCurrent, CLOCKS_PER_SEC * 30) != 0)          p->ulMainThreadId = GetCurrentThreadId();
503    
504            if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0)
505          {          {
506                  syslog << logfile::log_head << "Register thread ... Failed" << endl;                  syslog << logfile::log_head << "Register thread ... Failed" << endl;
507          }          }
508          p->GetParentThread()->GetThreadPool()->SetThreadStatus(hThreadCurrent,thread_pool::S_WORKING);          p->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING);
509    
510          p->w_call();          p->w_call();
511    
512          if (p->GetParentThread()->GetThreadPool()->RemoveThread(hThreadCurrent) != 0)          if (p->GetParentThread()->GetThreadPool()->RemoveThread(GetCurrentThreadId()) != 0)
513          {          {
514                  syslog << logfile::log_head << "Unregister thread ... Failed" << endl;                  syslog << logfile::log_head << "Unregister thread ... Failed" << endl;
515          }          }
# Line 549  int base::Startup(void) Line 553  int base::Startup(void)
553  {  {
554          return 0;          return 0;
555  }  }
556    
557    bool base::IsThreadActive(void)
558    {
559            bool bIsActive = false;
560    
561            switch (this->GetParentThread()->GetThreadPool()->GetThreadStatus(this->ulMainThreadId))
562            {
563            case thread_pool::S_WAITING:
564            case thread_pool::S_WORKING:
565                    bIsActive = true;
566                    break;
567            default:
568                    bIsActive = false;
569            }
570    
571            return bIsActive;
572    }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1