Fix functions overload resolution.

This commit is contained in:
Xie Han
2024-12-14 03:40:36 +08:00
parent fe5197a9df
commit 59ac643ccb
3 changed files with 50 additions and 6 deletions

View File

@@ -312,7 +312,7 @@ void KafkaClientTask::kafka_rebalance_callback(__WFKafkaTask *task)
snprintf(name, 64, "%p.cgroup", member);
member->mutex.unlock();
WFTaskFactory::signal_by_name(name, NULL, max);
WFTaskFactory::signal_by_name(name, (void *)NULL, max);
}
else
{

View File

@@ -382,6 +382,50 @@ public:
task->sub_series()->set_last_task(last);
return task;
}
private:
/* Some compilers don't declare 'nullptr_t' although required by C++11. */
using nullptr_t = std::nullptr_t;
public:
/* The following functions are for overload resolution only. */
#ifdef _WIN32
static int send_by_name(const std::string& mailbox_name, int msg,
size_t max)
{
return WFTaskFactory::send_by_name(mailbox_name, (void *)msg, max);
}
static int signal_by_name(const std::string& cond_name, int msg,
size_t max)
{
return WFTaskFactory::signal_by_name(cond_name, (void *)msg, max);
}
#else
static int send_by_name(const std::string& mailbox_name, intptr_t msg,
size_t max)
{
return WFTaskFactory::send_by_name(mailbox_name, (void *)msg, max);
}
static int signal_by_name(const std::string& cond_name, intptr_t msg,
size_t max)
{
return WFTaskFactory::signal_by_name(cond_name, (void *)msg, max);
}
#endif
static int send_by_name(const std::string& mailbox_name, nullptr_t msg,
size_t max)
{
return WFTaskFactory::send_by_name(mailbox_name, (void *)0, max);
}
static int signal_by_name(const std::string& cond_name, nullptr_t msg,
size_t max)
{
return WFTaskFactory::signal_by_name(cond_name, (void *)0, max);
}
};
template<class REQ, class RESP>

View File

@@ -712,7 +712,7 @@ void WFTaskFactory::reset_go_task(WFGoTask *task, FUNC&& func, ARGS&&... args)
template<> inline
WFGoTask *WFTaskFactory::create_go_task(const std::string& queue_name,
std::nullptr_t&& func)
nullptr_t&& func)
{
return new __WFGoTask(WFGlobal::get_exec_queue(queue_name),
WFGlobal::get_compute_executor(),
@@ -722,7 +722,7 @@ WFGoTask *WFTaskFactory::create_go_task(const std::string& queue_name,
template<> inline
WFGoTask *WFTaskFactory::create_timedgo_task(time_t seconds, long nanoseconds,
const std::string& queue_name,
std::nullptr_t&& func)
nullptr_t&& func)
{
return new __WFTimedGoTask(seconds, nanoseconds,
WFGlobal::get_exec_queue(queue_name),
@@ -732,7 +732,7 @@ WFGoTask *WFTaskFactory::create_timedgo_task(time_t seconds, long nanoseconds,
template<> inline
WFGoTask *WFTaskFactory::create_go_task(ExecQueue *queue, Executor *executor,
std::nullptr_t&& func)
nullptr_t&& func)
{
return new __WFGoTask(queue, executor, nullptr);
}
@@ -740,13 +740,13 @@ WFGoTask *WFTaskFactory::create_go_task(ExecQueue *queue, Executor *executor,
template<> inline
WFGoTask *WFTaskFactory::create_timedgo_task(time_t seconds, long nanoseconds,
ExecQueue *queue, Executor *executor,
std::nullptr_t&& func)
nullptr_t&& func)
{
return new __WFTimedGoTask(seconds, nanoseconds, queue, executor, nullptr);
}
template<> inline
void WFTaskFactory::reset_go_task(WFGoTask *task, std::nullptr_t&& func)
void WFTaskFactory::reset_go_task(WFGoTask *task, nullptr_t&& func)
{
((__WFGoTask *)task)->set_go_func(nullptr);
}