Skip to content

Commit

Permalink
Remove NOMINMAX
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-jia committed Oct 12, 2022
1 parent 7418ab3 commit 3a38e1c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
10 changes: 5 additions & 5 deletions include/kafka/KafkaProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class KafkaProducer: public KafkaClient
* Possible error values:
* - RD_KAFKA_RESP_ERR__TIMED_OUT: The `timeout` was reached before all outstanding requests were completed.
*/
Error flush(std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
Error flush(std::chrono::milliseconds timeout = InfiniteTimeout);

/**
* Purge messages currently handled by the KafkaProducer.
Expand All @@ -64,7 +64,7 @@ class KafkaProducer: public KafkaClient
/**
* Close this producer. This method would wait up to timeout for the producer to complete the sending of all incomplete requests (before purging them).
*/
void close(std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
void close(std::chrono::milliseconds timeout = InfiniteTimeout);

/**
* Options for sending messages.
Expand Down Expand Up @@ -142,7 +142,7 @@ class KafkaProducer: public KafkaClient
/**
* Needs to be called before any other methods when the transactional.id is set in the configuration.
*/
void initTransactions(std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
void initTransactions(std::chrono::milliseconds timeout = InfiniteTimeout);

/**
* Should be called before the start of each new transaction.
Expand All @@ -152,12 +152,12 @@ class KafkaProducer: public KafkaClient
/**
* Commit the ongoing transaction.
*/
void commitTransaction(std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
void commitTransaction(std::chrono::milliseconds timeout = InfiniteTimeout);

/**
* Abort the ongoing transaction.
*/
void abortTransaction(std::chrono::milliseconds timeout = std::chrono::milliseconds::max());
void abortTransaction(std::chrono::milliseconds timeout = InfiniteTimeout);


/**
Expand Down
3 changes: 0 additions & 3 deletions include/kafka/Project.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
// #define KAFKA_API_ENABLE_UNIT_TEST_STUBS
// #endif

#if defined(WIN32) && !defined(NOMINMAX)
#define NOMINMAX
#endif

#if ((__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L))
#define COMPILER_SUPPORTS_CPP_17 1
Expand Down
11 changes: 11 additions & 0 deletions include/kafka/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ class ConstBuffer
std::size_t _size;
};


/**
* Infinite timeout.
*/
#if COMPILER_SUPPORTS_CPP_17
const inline std::chrono::milliseconds InfiniteTimeout = (std::chrono::milliseconds::max)();
#else
const static std::chrono::milliseconds InfiniteTimeout = (std::chrono::milliseconds::max)();
#endif


/**
* Topic name.
*/
Expand Down
10 changes: 5 additions & 5 deletions include/kafka/addons/KafkaRecoverableProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class KafkaRecoverableProducer
* Possible error values:
* - RD_KAFKA_RESP_ERR__TIMED_OUT: The `timeout` was reached before all outstanding requests were completed.
*/
Error flush(std::chrono::milliseconds timeout = std::chrono::milliseconds::max())
Error flush(std::chrono::milliseconds timeout = InfiniteTimeout)
{
std::lock_guard<std::mutex> lock(_producerMutex);

Expand All @@ -158,7 +158,7 @@ class KafkaRecoverableProducer
/**
* Close this producer. This method would wait up to timeout for the producer to complete the sending of all incomplete requests (before purging them).
*/
void close(std::chrono::milliseconds timeout = std::chrono::milliseconds::max())
void close(std::chrono::milliseconds timeout = InfiniteTimeout)
{
std::lock_guard<std::mutex> lock(_producerMutex);

Expand Down Expand Up @@ -247,7 +247,7 @@ class KafkaRecoverableProducer
/**
* Needs to be called before any other methods when the transactional.id is set in the configuration.
*/
void initTransactions(std::chrono::milliseconds timeout = std::chrono::milliseconds::max())
void initTransactions(std::chrono::milliseconds timeout = InfiniteTimeout)
{
std::lock_guard<std::mutex> lock(_producerMutex);

Expand All @@ -267,7 +267,7 @@ class KafkaRecoverableProducer
/**
* Commit the ongoing transaction.
*/
void commitTransaction(std::chrono::milliseconds timeout = std::chrono::milliseconds::max())
void commitTransaction(std::chrono::milliseconds timeout = InfiniteTimeout)
{
std::lock_guard<std::mutex> lock(_producerMutex);

Expand All @@ -277,7 +277,7 @@ class KafkaRecoverableProducer
/**
* Abort the ongoing transaction.
*/
void abortTransaction(std::chrono::milliseconds timeout = std::chrono::milliseconds::max())
void abortTransaction(std::chrono::milliseconds timeout = InfiniteTimeout)
{
std::lock_guard<std::mutex> lock(_producerMutex);

Expand Down

0 comments on commit 3a38e1c

Please sign in to comment.