Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ace / Compression / Compressor.cpp
blob74ff168aa6e7614bb0d4f1e9b1cf4f311f90cd15
1 #include "Compressor.h"
3 #if !defined (__ACE_INLINE__)
4 #include "Compressor.inl"
5 #endif /* __ACE_INLINE__ */
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 ACE_Compressor::ACE_Compressor(ACE_CompressorId compressor_id,
10 ACE_UINT32 compression_level)
11 : compressor_id_ (compressor_id)
12 , compression_level_ (compression_level)
13 , compressed_bytes_ (0)
14 , uncompressed_bytes_ (0)
17 ACE_UINT64
18 ACE_Compressor::compressed_bytes() const
20 ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0 );
21 return this->compressed_bytes_;
24 ACE_UINT64
25 ACE_Compressor::uncompressed_bytes() const
27 ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0 );
28 return this->uncompressed_bytes_;
31 void
32 ACE_Compressor::reset_stats()
34 ACE_GUARD( ACE_SYNCH_MUTEX, ace_mon, this->mutex_ );
35 this->compressed_bytes_ = 0;
36 this->uncompressed_bytes_ = 0;
39 void
40 ACE_Compressor::update_stats(ACE_UINT64 uncompressed_bytes, ACE_UINT64 compressed_bytes)
42 ACE_GUARD( ACE_SYNCH_MUTEX, ace_mon, this->mutex_ );
43 this->compressed_bytes_ += compressed_bytes;
44 this->uncompressed_bytes_ += uncompressed_bytes;
47 float
48 ACE_Compressor::compression_ratio() const
50 ACE_GUARD_RETURN( ACE_SYNCH_MUTEX, ace_mon, this->mutex_, 0.0f );
51 if (this->uncompressed_bytes_ > 0) {
52 return static_cast<float>(this->compressed_bytes_) / this->uncompressed_bytes_;
54 return 0.0f;
57 ACE_END_VERSIONED_NAMESPACE_DECL