version 1.28, 2002/07/23 18:05:18
|
version 1.40, 2005/02/06 21:13:14
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// The Open Group, Tivoli Systems |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// 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 |
|
|
// | // |
// Author: Mike Day (mdday@us.ibm.com) | // Author: Mike Day (mdday@us.ibm.com) |
// | // |
// Modified By: |
// Modified By: Amit K Arora, IBM (amita@in.ibm.com) for Bug#1188 |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
|
// Sean Keenan (sean.keenan@hp.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/AsyncOpNode.h> | #include <Pegasus/Common/AsyncOpNode.h> |
#include <Pegasus/Common/Exception.h> |
#include <Pegasus/Common/InternalException.h> |
|
|
|
#if defined(PEGASUS_OS_VMS) |
|
#include <stdio.h> |
|
#endif |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
|
#define snprintf _snprintf | #define snprintf _snprintf |
#endif | #endif |
| |
AsyncOpNode * AsyncOpNode::_headOfFreeList; |
// AsyncOpNode * AsyncOpNode::_headOfFreeList; |
const int AsyncOpNode::BLOCK_SIZE = 200; |
// const int AsyncOpNode::BLOCK_SIZE = 200; |
Mutex AsyncOpNode::_alloc_mut; |
// Mutex AsyncOpNode::_alloc_mut; |
|
|
void * AsyncOpNode::operator new(size_t size) |
// void * AsyncOpNode::operator new(size_t size) |
{ |
// { |
if(size != sizeof(AsyncOpNode)) |
// if(size != sizeof(AsyncOpNode)) |
return :: operator new(size); |
// return :: operator new(size); |
|
|
_alloc_mut.lock(pegasus_thread_self()); |
// _alloc_mut.lock(pegasus_thread_self()); |
|
|
AsyncOpNode *node = _headOfFreeList; |
// AsyncOpNode *node = _headOfFreeList; |
if(node) |
// if(node) |
_headOfFreeList = node->_parent; |
// _headOfFreeList = node->_parent; |
else |
// else |
{ |
// { |
AsyncOpNode * newBlock = |
// AsyncOpNode * newBlock = |
reinterpret_cast<AsyncOpNode *>(::operator new( BLOCK_SIZE * sizeof(AsyncOpNode))); |
// reinterpret_cast<AsyncOpNode *>(::operator new( BLOCK_SIZE * sizeof(AsyncOpNode))); |
int i; |
// int i; |
for( i = 1; i < BLOCK_SIZE - 1; ++i) |
// for( i = 1; i < BLOCK_SIZE - 1; ++i) |
newBlock[i]._parent = &newBlock[i + 1]; |
// newBlock[i]._parent = &newBlock[i + 1]; |
newBlock[BLOCK_SIZE - 1]._parent = NULL; |
// newBlock[BLOCK_SIZE - 1]._parent = NULL; |
node = newBlock; |
// node = newBlock; |
_headOfFreeList = &newBlock[1]; |
// _headOfFreeList = &newBlock[1]; |
} |
// } |
_alloc_mut.unlock(); |
// _alloc_mut.unlock(); |
return node; |
// return node; |
} |
// } |
|
|
void AsyncOpNode::operator delete(void *dead, size_t size) |
// void AsyncOpNode::operator delete(void *dead, size_t size) |
{ |
// { |
|
|
if(dead == 0) |
// if(dead == 0) |
return; |
// return; |
if(size != sizeof(AsyncOpNode)) |
// if(size != sizeof(AsyncOpNode)) |
{ |
// { |
::operator delete(dead); |
// ::operator delete(dead); |
return; |
// return; |
} |
// } |
AsyncOpNode *node = reinterpret_cast<AsyncOpNode *>(dead); |
// AsyncOpNode *node = reinterpret_cast<AsyncOpNode *>(dead); |
_alloc_mut.lock(pegasus_thread_self()); |
// _alloc_mut.lock(pegasus_thread_self()); |
node->_parent = _headOfFreeList; |
// node->_parent = _headOfFreeList; |
_headOfFreeList = node; |
// _headOfFreeList = node; |
_alloc_mut.unlock(); |
// _alloc_mut.unlock(); |
} |
// } |
| |
| |
AsyncOpNode::AsyncOpNode(void) | AsyncOpNode::AsyncOpNode(void) |
|
|
return; | return; |
} | } |
| |
void AsyncOpNode::print_to_buffer(Sint8 **buf) |
void AsyncOpNode::print_to_buffer(char **buf) |
{ | { |
if(buf == NULL) | if(buf == NULL) |
return; | return; |
| |
static Sint8 work_buf[4096]; |
#if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
snprintf(work_buf, 4096, "AsyncOpNode %p\n" \ |
char work_buf[512]; |
|
snprintf(work_buf, sizeof(work_buf), "AsyncOpNode %p\n" \ |
"\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \ | "\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \ |
"\tcallback node %p; callback rp q %p; callback ptr %p\n" \ | "\tcallback node %p; callback rp q %p; callback ptr %p\n" \ |
"\tcallback parm %p; callback handle %p; callback notify %p\n" \ | "\tcallback parm %p; callback handle %p; callback notify %p\n" \ |
|
|
_callback_ptr, _callback_parameter, _callback_handle, _callback_notify, | _callback_ptr, _callback_parameter, _callback_handle, _callback_notify, |
_callback_request_q, _service_ptr, _thread_ptr); | _callback_request_q, _service_ptr, _thread_ptr); |
*buf = strdup(work_buf); | *buf = strdup(work_buf); |
|
#endif |
return; | return; |
| |
} | } |
| |
String &AsyncOpNode::print_to_string(void) |
String AsyncOpNode::print_to_string(void) |
{ | { |
static Sint8 work_buf[4096]; |
char work_buf[512]; |
snprintf(work_buf, 4096, "AsyncOpNode %p\n" \ |
#if !defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
|
snprintf(work_buf, sizeof(work_buf), "AsyncOpNode %p\n" \ |
"\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \ | "\trq %d; rp %d; state %d; flags %d; op_dst q %p\n" \ |
"\tcallback node %p; callback rp q %p; callback ptr %p\n" \ | "\tcallback node %p; callback rp q %p; callback ptr %p\n" \ |
"\tcallback parm %p; callback handle %p; callback notify %p\n" \ | "\tcallback parm %p; callback handle %p; callback notify %p\n" \ |
|
|
_state, _flags, _op_dest, _callback_node, _callback_response_q, | _state, _flags, _op_dest, _callback_node, _callback_response_q, |
_callback_ptr, _callback_parameter, _callback_handle, _callback_notify, | _callback_ptr, _callback_parameter, _callback_handle, _callback_notify, |
_callback_request_q, _service_ptr, _thread_ptr); | _callback_request_q, _service_ptr, _thread_ptr); |
String *ret = new String(work_buf); |
#else |
|
work_buf[0] = '\0'; |
|
#endif |
| |
return *ret; |
return String(work_buf); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |