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

Diff for /pegasus/src/Pegasus/Common/AsyncOpNode.cpp between version 1.2 and 1.26

version 1.2, 2001/12/13 14:53:49 version 1.26, 2002/06/01 00:56:21
Line 1 
Line 1 
 //%//////////////////////////////////////////////////////////////////////////  //%/////////////////////////////////////////////////////////////////////////////
 // //
 // 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 27 
Line 28 
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/AsyncOpNode.h> #include <Pegasus/Common/AsyncOpNode.h>
   #include <Pegasus/Common/Exception.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 AsyncOpNode::AsyncOpNode(void)  AsyncOpNode * AsyncOpNode::_headOfFreeList;
    : _client_sem(1), _mut(), _request(0), _response(0),  const int AsyncOpNode::BLOCK_SIZE = 200;
      _state(0), _flags(0), _total_ops(0), _completed_ops(0),  Mutex AsyncOpNode::_alloc_mut;
      _parent(0), _children(true)  
   void * AsyncOpNode::operator new(size_t size)
   {
      if(size != sizeof(AsyncOpNode))
         return :: operator new(size);
   
      _alloc_mut.lock(pegasus_thread_self());
   
      AsyncOpNode *node = _headOfFreeList;
      if(node)
         _headOfFreeList = node->_parent;
      else
      {
         AsyncOpNode * newBlock =
            reinterpret_cast<AsyncOpNode *>(::operator new( BLOCK_SIZE * sizeof(AsyncOpNode)));
         int i;
         for( i = 1; i < BLOCK_SIZE - 1; ++i)
            newBlock[i]._parent = &newBlock[i + 1];
         newBlock[BLOCK_SIZE - 1]._parent = NULL;
         node = newBlock;
         _headOfFreeList = &newBlock[1];
      }
      _alloc_mut.unlock();
      return node;
   }
  
   void AsyncOpNode::operator delete(void *dead, size_t size)
   {
   
      if(dead == 0)
         return;
      if(size != sizeof(AsyncOpNode))
 { {
    memset(&_start, 0x00, sizeof(struct timeval));        ::operator delete(dead);
         return;
      }
      AsyncOpNode *node = reinterpret_cast<AsyncOpNode *>(dead);
      _alloc_mut.lock(pegasus_thread_self());
      node->_parent = _headOfFreeList;
      _headOfFreeList = node;
      _alloc_mut.unlock();
   }
   
   
   AsyncOpNode::AsyncOpNode(void)
      : _client_sem(0), _request(true), _response(true),
        _state(0), _flags(0), _offered_count(0), _total_ops(0), _completed_ops(0),
        _user_data(0), _completion_code(0), _op_dest(0),
        _parent(0), _children(true), _async_callback(0),__async_callback(0),
        _callback_node(0), _callback_response_q(0),
        _callback_ptr(0), _callback_parameter(0),
        _callback_handle(0), _callback_notify(0), _callback_request_q(0)
   {
      gettimeofday(&_start, NULL);
    memset(&_lifetime, 0x00, sizeof(struct timeval));    memset(&_lifetime, 0x00, sizeof(struct timeval));
    memset(&_updated, 0x00, sizeof(struct timeval));    memset(&_updated, 0x00, sizeof(struct timeval));
    memset(&_timeout_interval, 0xff, sizeof(struct timeval));      _timeout_interval.tv_sec = 60;
      _timeout_interval.tv_usec = 100;
 } }
  
 AsyncOpNode::~AsyncOpNode(void) AsyncOpNode::~AsyncOpNode(void)
 { {
    delete _request;     _request.empty_list();
    delete _response;     _response.empty_list();
 } }
  
   
 void AsyncOpNode::_reset(unlocked_dq<AsyncOpNode> *dst_q) void AsyncOpNode::_reset(unlocked_dq<AsyncOpNode> *dst_q)
 { {
    AsyncOpNode *child = _children.remove_first();    AsyncOpNode *child = _children.remove_first();
Line 59 
Line 111 
    }    }
  
    _parent = 0;    _parent = 0;
    delete _request;     _request.empty_list();
    delete _response;     _response.empty_list();
    _operation_list.reset();  
      //_operation_list.reset();
    _state = 0;    _state = 0;
    _flags = 0;    _flags = 0;
      _offered_count = 0;
    _total_ops = 0;    _total_ops = 0;
    _completed_ops = 0;    _completed_ops = 0;
      _user_data = 0;
      _completion_code = 0;
      _op_dest = 0;
      _async_callback = 0;
      __async_callback = 0;
      _callback_node =0;
      _callback_response_q = 0;
      _callback_ptr=0;
      _callback_parameter = 0;
      _callback_handle = 0;
      _callback_notify = 0;
      _callback_request_q = 0;
    dst_q->insert_first(this);    dst_q->insert_first(this);
      while ( _client_sem.count() )
         _client_sem.wait();
      PEGASUS_ASSERT( _client_sem.count() == 0 );
   
    return;    return;
 } }
  
   
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.26

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2