(file) Return to MessageQueueService.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/MessageQueueService.cpp between version 1.53 and 1.62

version 1.53, 2002/06/07 00:03:32 version 1.62, 2002/07/12 23:10:04
Line 1 
Line 1 
 //%////-*-c++-*-//////////////////////////////////////////////////////////////// //%////-*-c++-*-////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM  // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM,
   // The Open Group, Tivoli Systems
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 37 
Line 38 
 AtomicInt MessageQueueService::_xid(1); AtomicInt MessageQueueService::_xid(1);
 Mutex MessageQueueService::_meta_dispatcher_mutex; Mutex MessageQueueService::_meta_dispatcher_mutex;
  
 static struct timeval create_time = {0, 100};  static struct timeval create_time = {0, 1};
 static struct timeval destroy_time = {1, 0};  static struct timeval destroy_time = {15, 0};
 static struct timeval deadlock_time = {10, 0};  static struct timeval deadlock_time = {0, 0};
  
 ThreadPool MessageQueueService::_thread_pool(2, "MessageQueueService", 2, 20,  ThreadPool *MessageQueueService::_thread_pool = 0;
                                              create_time, destroy_time, deadlock_time);  
  
 DQueue<MessageQueueService> MessageQueueService::_polling_list(true); DQueue<MessageQueueService> MessageQueueService::_polling_list(true);
  
   Thread* MessageQueueService::_polling_thread = 0;
   
   
 int MessageQueueService::kill_idle_threads(void) int MessageQueueService::kill_idle_threads(void)
 { {
    static struct timeval now, last;    static struct timeval now, last;
    gettimeofday(&now, NULL);    gettimeofday(&now, NULL);
      int dead_threads = 0;
  
    if( now.tv_sec - last.tv_sec > 0 )    if( now.tv_sec - last.tv_sec > 0 )
    {    {
       gettimeofday(&last, NULL);       gettimeofday(&last, NULL);
       return _thread_pool.kill_dead_threads();        try
         {
            dead_threads =  _thread_pool->kill_dead_threads();
    }    }
    return 0;        catch(IPCException& )
         {
   
         }
      }
      return dead_threads;
 } }
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::polling_routine(void *parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::polling_routine(void *parm)
 { {
    Thread *myself = reinterpret_cast<Thread *>(parm);    Thread *myself = reinterpret_cast<Thread *>(parm);
   
    DQueue<MessageQueueService> *list = reinterpret_cast<DQueue<MessageQueueService> *>(myself->get_parm());    DQueue<MessageQueueService> *list = reinterpret_cast<DQueue<MessageQueueService> *>(myself->get_parm());
   
    while ( _stop_polling.value()  == 0 )    while ( _stop_polling.value()  == 0 )
    {    {
       _polling_sem.wait();       _polling_sem.wait();
         if(_stop_polling.value() != 0 )
         {
            break;
         }
   
       list->lock();       list->lock();
       MessageQueueService *service = list->next(0);       MessageQueueService *service = list->next(0);
       while(service != NULL)       while(service != NULL)
       {       {
          if(service->_incoming.count() > 0 )          if(service->_incoming.count() > 0 )
          {          {
             _thread_pool.allocate_and_awaken(service, _req_proc);              _thread_pool->allocate_and_awaken(service, _req_proc);
   
 //          service->_req_proc(service); //          service->_req_proc(service);
          }          }
   
          service = list->next(service);          service = list->next(service);
       }       }
       list->unlock();       list->unlock();
Line 87 
Line 99 
    return(0);    return(0);
 } }
  
 Thread MessageQueueService::_polling_thread(polling_routine,  
                                             reinterpret_cast<void *>(&_polling_list),  
                                             false);  
   
  
 Semaphore MessageQueueService::_polling_sem(0); Semaphore MessageQueueService::_polling_sem(0);
 AtomicInt MessageQueueService::_stop_polling(0); AtomicInt MessageQueueService::_stop_polling(0);
Line 112 
Line 120 
      _callback_thread(_callback_proc, this, false)      _callback_thread(_callback_proc, this, false)
  
 { {
   
    _capabilities = (capabilities | module_capabilities::async);    _capabilities = (capabilities | module_capabilities::async);
  
    _default_op_timeout.tv_sec = 30;    _default_op_timeout.tv_sec = 30;
Line 128 
Line 137 
          _meta_dispatcher_mutex.unlock();          _meta_dispatcher_mutex.unlock();
          throw NullPointer();          throw NullPointer();
       }       }
       _polling_thread.run();        _thread_pool = new ThreadPool(0, "MessageQueueService", 0, 0,
                                       create_time, destroy_time, deadlock_time);
   
         _polling_thread = new Thread(polling_routine,
                                      reinterpret_cast<void *>(&_polling_list),
                                      false);
         _polling_thread->run();
    }    }
    _service_count++;    _service_count++;
  
Line 163 
Line 178 
    {    {
       _stop_polling++;       _stop_polling++;
       _polling_sem.signal();       _polling_sem.signal();
       _polling_thread.join();        _polling_thread->join();
         delete _polling_thread;
       _meta_dispatcher->_shutdown_routed_queue();       _meta_dispatcher->_shutdown_routed_queue();
       delete _meta_dispatcher;       delete _meta_dispatcher;
       _meta_dispatcher = 0;       _meta_dispatcher = 0;
Line 248 
Line 264 
  
 PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::_req_proc(void * parm) PEGASUS_THREAD_RETURN PEGASUS_THREAD_CDECL MessageQueueService::_req_proc(void * parm)
 { {
 //   Thread *myself = reinterpret_cast<Thread *>(parm);  
 //   MessageQueueService *service = reinterpret_cast<MessageQueueService *>(myself->get_parm());  
    MessageQueueService *service = reinterpret_cast<MessageQueueService *>(parm);    MessageQueueService *service = reinterpret_cast<MessageQueueService *>(parm);
    // pull messages off the incoming queue and dispatch them. then    // pull messages off the incoming queue and dispatch them. then
    // check pending messages that are non-blocking    // check pending messages that are non-blocking
    AsyncOpNode *operation = 0;    AsyncOpNode *operation = 0;
  
 //    while ( service->_die.value() == 0 )     if ( service->_die.value() == 0 )
 //    {      {
          try          try
          {          {
             operation = service->_incoming.remove_first();             operation = service->_incoming.remove_first();
          }          }
          catch(ListClosed & )          catch(ListClosed & )
          {          {
 //          break;              operation = 0;
   
               return(0);
          }          }
          if( operation )          if( operation )
          {          {
 //          operation->_thread_ptr = pegasus_thread_self();  
             operation->_service_ptr = service;             operation->_service_ptr = service;
             service->_handle_incoming_operation(operation);             service->_handle_incoming_operation(operation);
          }          }
 //    }      }
  
 //    myself->exit_self( (PEGASUS_THREAD_RETURN) 1 );  
    return(0);    return(0);
 } }
  
Line 477 
Line 491 
       // remove it from the op node       // remove it from the op node
       op->_request.remove(request);       op->_request.remove(request);
  
   
       AsyncLegacyOperationResult *async_result =       AsyncLegacyOperationResult *async_result =
          new AsyncLegacyOperationResult(          new AsyncLegacyOperationResult(
             async->getKey(),             async->getKey(),


Legend:
Removed from v.1.53  
changed lines
  Added in v.1.62

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2