esp8266 / Arduino

ESP8266 core for Arduino
GNU Lesser General Public License v2.1
16.01k stars 13.33k forks source link

std::mutex is not available #8882

Open ghost opened 1 year ago

ghost commented 1 year ago

Basic Infos

Platform

Settings in IDE

Problem Description

std::mutex is not available. Have set up a Win10 VM and fresh installed VS Code and PIO to ensure it is not related to one of my libraries or such. Still persists.

MCVE Sketch

main.cpp:

#include <Arduino.h>

#include <mutex>

using std::mutex;

void setup() {}

void loop() {}

platformio.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino

Output

src\main.cpp:5:12: error: 'mutex' has not been declared in 'std'
    5 | using std::mutex;
      |            ^~~~~
*** [.pio\build\d1_mini\src\main.cpp.o] Error 1
d-a-v commented 1 year ago

Our toolchain is not configured to build and provide the thread library (_GLIBCXX_HAS_GTHREADS is not defined). There is currently no multithreading enabled in this architecture because this is useless until proven wrong: The scheduling model of NONOS-SDK firmware on top of which we are running is single-task even though we know that freertos is running under the hood.

The arduino API cli() and sei() is implemented and accessible for global / critical locking.

edit interrupts() and noInterrupts() are their official names (thanks @dok-net for pointing this out)

dok-net commented 1 year ago

According to https://www.arduino.cc/reference/en/, the portable calls are interrupts() and noInterrupts(), are they not? Obviously you must not yield() (delay(), sleep etc.) when noInterrupts() is in effect.