version 1.2, 2006/08/29 17:48:56
|
version 1.3, 2006/09/01 17:51:30
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include "ProviderStatus.h" | #include "ProviderStatus.h" |
|
#include <Pegasus/Common/Time.h> |
|
#include <Pegasus/Common/PegasusAssert.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
ProviderStatus::ProviderStatus() | ProviderStatus::ProviderStatus() |
: _cimom_handle(0), |
|
_module(0), |
|
_isInitialized(false), |
|
_noUnload(0), |
|
_currentOperations(0), |
|
_indicationsEnabled(false), |
|
_currentSubscriptions(0) |
|
{ | { |
|
setInitialized(false); |
} | } |
| |
ProviderStatus::~ProviderStatus() | ProviderStatus::~ProviderStatus() |
|
|
{ | { |
AutoMutex lock(_statusMutex); | AutoMutex lock(_statusMutex); |
_isInitialized = initialized; | _isInitialized = initialized; |
|
|
|
if (!_isInitialized) |
|
{ |
|
_module = 0; |
|
_cimomHandle = 0; |
|
_currentOperations = 0; |
|
_indicationsEnabled = false; |
|
_currentSubscriptions = 0; |
|
} |
|
|
|
Time::gettimeofday(&_lastOperationEndTime); |
} | } |
| |
ProviderModule* ProviderStatus::getModule() const | ProviderModule* ProviderStatus::getModule() const |
|
|
_module = module; | _module = module; |
} | } |
| |
void ProviderStatus::setCIMOMHandle(CIMOMHandle* cimomHandle) |
CIMOMHandle* ProviderStatus::getCIMOMHandle() |
{ | { |
_cimom_handle = cimomHandle; |
return _cimomHandle; |
} | } |
| |
void ProviderStatus::reset() |
void ProviderStatus::setCIMOMHandle(CIMOMHandle* cimomHandle) |
{ | { |
_cimom_handle = 0; |
_cimomHandle = cimomHandle; |
_module = 0; |
|
_noUnload = 0; |
|
_isInitialized = false; |
|
} | } |
| |
void ProviderStatus::get_idle_timer(struct timeval* t) |
void ProviderStatus::getLastOperationEndTime(struct timeval* t) |
{ |
|
if (t && _cimom_handle) |
|
{ | { |
_cimom_handle->get_idle_timer(t); |
PEGASUS_ASSERT(t != 0); |
} |
AutoMutex lock(_lastOperationEndTimeMutex); |
|
memcpy(t, &_lastOperationEndTime, sizeof(struct timeval)); |
} | } |
| |
void ProviderStatus::update_idle_timer() |
Boolean ProviderStatus::isIdle() |
{ | { |
if (_cimom_handle) |
if (!_isInitialized || |
|
(_currentOperations.get() > 0) || |
|
_indicationsEnabled) |
{ | { |
_cimom_handle->update_idle_timer(); |
return false; |
} |
|
} | } |
| |
Boolean ProviderStatus::pending_operation() |
if (_cimomHandle) |
{ | { |
if (_cimom_handle) |
return _cimomHandle->unload_ok(); |
{ |
|
return _cimom_handle->pending_operation(); |
|
} | } |
| |
return false; |
return true; |
} | } |
| |
|
void ProviderStatus::operationBegin() |
Boolean ProviderStatus::unload_ok() |
|
{ |
|
if (!_isInitialized || _noUnload.get()) |
|
{ | { |
return false; |
_currentOperations++; |
} | } |
| |
if (_cimom_handle) |
void ProviderStatus::operationEnd() |
{ | { |
return _cimom_handle->unload_ok(); |
_currentOperations--; |
|
|
|
// Update the timer used to detect idle providers |
|
AutoMutex lock(_lastOperationEndTimeMutex); |
|
Time::gettimeofday(&_lastOperationEndTime); |
} | } |
| |
return true; |
Uint32 ProviderStatus::numCurrentOperations() const |
|
{ |
|
return _currentOperations.get(); |
} | } |
| |
void ProviderStatus::protect() |
Boolean ProviderStatus::getIndicationsEnabled() const |
{ | { |
_noUnload++; |
return _indicationsEnabled; |
} | } |
| |
void ProviderStatus::unprotect() |
void ProviderStatus::setIndicationsEnabled(Boolean indicationsEnabled) |
{ | { |
_noUnload--; |
_indicationsEnabled = indicationsEnabled; |
} | } |
| |
Boolean ProviderStatus::testIfZeroAndIncrementSubscriptions() | Boolean ProviderStatus::testIfZeroAndIncrementSubscriptions() |
|
|
return _providerInstance; | return _providerInstance; |
} | } |
| |
|
Mutex& ProviderStatus::getStatusMutex() |
|
{ |
|
return _statusMutex; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |