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,14 +97,14 @@ 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();
|
||||
}
|
||||
@ -137,10 +137,10 @@ bool MDNSResponder::begin(const char* p_pcHostname,
|
||||
*/
|
||||
bool MDNSResponder::close(void) {
|
||||
|
||||
m_GotIPHandler.reset(); // reset WiFi event callbacks.
|
||||
m_DisconnectedHandler.reset();
|
||||
m_GotIPHandler.reset(); // reset WiFi event callbacks.
|
||||
m_DisconnectedHandler.reset();
|
||||
|
||||
_announce(false, true);
|
||||
_announce(false, true);
|
||||
_resetProbeStatus(false); // Stop probing
|
||||
|
||||
_releaseServiceQueries();
|
||||
@ -159,7 +159,7 @@ bool MDNSResponder::close(void) {
|
||||
*/
|
||||
|
||||
bool MDNSResponder::end(void) {
|
||||
return close();
|
||||
return close();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -832,11 +832,11 @@ uint32_t MDNSResponder::answerCount(const MDNSResponder::hMDNSServiceQuery p_hSe
|
||||
|
||||
std::vector<MDNSResponder::MDNSServiceInfo> MDNSResponder::answerInfo (const MDNSResponder::hMDNSServiceQuery p_hServiceQuery) {
|
||||
std::vector<MDNSResponder::MDNSServiceInfo> tempVector;
|
||||
for (uint32_t i=0;i<answerCount(p_hServiceQuery);i++)
|
||||
for (uint32_t i=0;i<answerCount(p_hServiceQuery);i++)
|
||||
{
|
||||
tempVector.emplace_back(*this,p_hServiceQuery,i);
|
||||
tempVector.emplace_back(*this,p_hServiceQuery,i);
|
||||
}
|
||||
return tempVector;
|
||||
return tempVector;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1053,14 +1053,14 @@ const char* MDNSResponder::answerTxts(const MDNSResponder::hMDNSServiceQuery p_h
|
||||
*/
|
||||
bool MDNSResponder::setHostProbeResultCallback(MDNSResponder::MDNSHostProbeFn p_fnCallback) {
|
||||
|
||||
m_HostProbeInformation.m_fnHostProbeResultCallback = p_fnCallback;
|
||||
m_HostProbeInformation.m_fnHostProbeResultCallback = p_fnCallback;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MDNSResponder::setHostProbeResultCallback(MDNSHostProbeFn1 pfn) {
|
||||
using namespace std::placeholders;
|
||||
return setHostProbeResultCallback(std::bind(pfn, std::ref(*this), _1, _2));
|
||||
using namespace std::placeholders;
|
||||
return setHostProbeResultCallback([resp=std::ref(*this), pfn](const char* p_pcDomainName, bool p_bProbeResult) { pfn(resp, p_pcDomainName, p_bProbeResult); });
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1088,8 +1088,10 @@ 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));
|
||||
using namespace std::placeholders;
|
||||
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