mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
The use of bind in Ticker.h is prone to type inference failure (#6129)
* std::bind has issues with type inference, use lambdas whereever possible. * Fix indentation. * More descriptive placeholder name in lambda expression * Use formal argument names for remaining currying placeholders
This commit is contained in:
parent
09f6b87ef5
commit
2d9253e46c
@ -97,13 +97,13 @@ bool MDNSResponder::begin(const char* p_pcHostname) {
|
||||
m_GotIPHandler = WiFi.onStationModeGotIP([this](const WiFiEventStationModeGotIP& pEvent) {
|
||||
(void) pEvent;
|
||||
// Ensure that _restart() runs in USER context
|
||||
schedule_function(std::bind(&MDNSResponder::_restart, this));
|
||||
schedule_function([this]() { MDNSResponder::_restart(); });
|
||||
});
|
||||
|
||||
m_DisconnectedHandler = WiFi.onStationModeDisconnected([this](const WiFiEventStationModeDisconnected& pEvent) {
|
||||
(void) pEvent;
|
||||
// Ensure that _restart() runs in USER context
|
||||
schedule_function(std::bind(&MDNSResponder::_restart, this));
|
||||
schedule_function([this]() { MDNSResponder::_restart(); });
|
||||
});
|
||||
|
||||
bResult = _restart();
|
||||
@ -1060,7 +1060,7 @@ bool MDNSResponder::setHostProbeResultCallback(MDNSResponder::MDNSHostProbeFn p_
|
||||
|
||||
bool MDNSResponder::setHostProbeResultCallback(MDNSHostProbeFn1 pfn) {
|
||||
using namespace std::placeholders;
|
||||
return setHostProbeResultCallback(std::bind(pfn, std::ref(*this), _1, _2));
|
||||
return setHostProbeResultCallback([resp=std::ref(*this), pfn](const char* p_pcDomainName, bool p_bProbeResult) { pfn(resp, p_pcDomainName, p_bProbeResult); });
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1089,7 +1089,9 @@ bool MDNSResponder::setServiceProbeResultCallback(const MDNSResponder::hMDNSServ
|
||||
bool MDNSResponder::setServiceProbeResultCallback(const MDNSResponder::hMDNSService p_hService,
|
||||
MDNSResponder::MDNSServiceProbeFn1 p_fnCallback) {
|
||||
using namespace std::placeholders;
|
||||
return setServiceProbeResultCallback(p_hService, std::bind(p_fnCallback, std::ref(*this), _1, _2, _3));
|
||||
return setServiceProbeResultCallback(p_hService, [resp=std::ref(*this), p_fnCallback](const char* p_pcServiceName, const hMDNSService p_hMDNSService, bool p_bProbeResult) {
|
||||
p_fnCallback(resp, p_pcServiceName, p_hMDNSService, p_bProbeResult);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
void attach_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
attach(seconds,std::bind(schedule_function, callback));
|
||||
attach(seconds, [callback]() { schedule_function(callback); });
|
||||
}
|
||||
|
||||
void attach(float seconds, callback_function_t callback)
|
||||
@ -54,7 +54,7 @@ public:
|
||||
|
||||
void attach_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
attach_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
attach_ms(milliseconds, [callback]() { schedule_function(callback); });
|
||||
}
|
||||
|
||||
void attach_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
@ -84,7 +84,7 @@ public:
|
||||
|
||||
void once_scheduled(float seconds, callback_function_t callback)
|
||||
{
|
||||
once(seconds, std::bind(schedule_function, callback));
|
||||
once(seconds, [callback]() { schedule_function(callback); });
|
||||
}
|
||||
|
||||
void once(float seconds, callback_function_t callback)
|
||||
@ -95,7 +95,7 @@ public:
|
||||
|
||||
void once_ms_scheduled(uint32_t milliseconds, callback_function_t callback)
|
||||
{
|
||||
once_ms(milliseconds, std::bind(schedule_function, callback));
|
||||
once_ms(milliseconds, [callback]() { schedule_function(callback); });
|
||||
}
|
||||
|
||||
void once_ms(uint32_t milliseconds, callback_function_t callback)
|
||||
|
Loading…
x
Reference in New Issue
Block a user