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)
18 ACE_Compressor::compressed_bytes() const
20 ACE_GUARD_RETURN( ACE_SYNCH_MUTEX
, ace_mon
, this->mutex_
, 0 );
21 return this->compressed_bytes_
;
25 ACE_Compressor::uncompressed_bytes() const
27 ACE_GUARD_RETURN( ACE_SYNCH_MUTEX
, ace_mon
, this->mutex_
, 0 );
28 return this->uncompressed_bytes_
;
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;
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
;
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_
;
57 ACE_END_VERSIONED_NAMESPACE_DECL