diff --git a/examples/avr/fiber/main.cpp b/examples/avr/fiber/main.cpp index 89065e4270..bdb0aaaf3f 100644 --- a/examples/avr/fiber/main.cpp +++ b/examples/avr/fiber/main.cpp @@ -24,14 +24,14 @@ void fiber_function1() { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f1counter < cycles) { modm::fiber::yield(); total_counter++; } + while (++f1counter < cycles) { modm::this_fiber::yield(); total_counter++; } } void fiber_function2(uint32_t cyc) { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f2counter < cyc) { modm::fiber::yield(); total_counter++; } + while (++f2counter < cyc) { modm::this_fiber::yield(); total_counter++; } } struct Test @@ -40,14 +40,14 @@ struct Test fiber_function3() { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f3counter < cycles) { modm::fiber::yield(); total_counter++; } + while (++f3counter < cycles) { modm::this_fiber::yield(); total_counter++; } } void fiber_function4(uint32_t cyc) { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f4counter < cyc) { modm::fiber::yield(); total_counter++; } + while (++f4counter < cyc) { modm::this_fiber::yield(); total_counter++; } } volatile uint32_t f3counter{0}; diff --git a/examples/generic/fiber/main.cpp b/examples/generic/fiber/main.cpp index 9331388171..2965b627bd 100644 --- a/examples/generic/fiber/main.cpp +++ b/examples/generic/fiber/main.cpp @@ -26,14 +26,14 @@ void fiber_function1() { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f1counter < cycles) { modm::fiber::yield(); total_counter++; } + while (++f1counter < cycles) { modm::this_fiber::yield(); total_counter++; } } void fiber_function2(uint32_t cyc) { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f2counter < cyc) { modm::fiber::yield(); total_counter++; } + while (++f2counter < cyc) { modm::this_fiber::yield(); total_counter++; } } struct Test @@ -42,14 +42,14 @@ struct Test fiber_function3() { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f3counter < cycles) { modm::fiber::yield(); total_counter++; } + while (++f3counter < cycles) { modm::this_fiber::yield(); total_counter++; } } void fiber_function4(uint32_t cyc) { MODM_LOG_INFO << MODM_FILE_INFO << modm::endl; - while (++f4counter < cyc) { modm::fiber::yield(); total_counter++; } + while (++f4counter < cyc) { modm::this_fiber::yield(); total_counter++; } } volatile uint32_t f3counter{0}; @@ -57,8 +57,8 @@ struct Test } test; // Single purpose fibers to time the yield -modm_faststack modm::Fiber<> fiber_y1([](){ modm::fiber::yield(); counter.stop(); }); -modm_faststack modm::Fiber<> fiber_y2([](){ counter.start(); modm::fiber::yield(); }); +modm_faststack modm::Fiber<> fiber_y1([](){ modm::this_fiber::yield(); counter.stop(); }); +modm_faststack modm::Fiber<> fiber_y2([](){ counter.start(); modm::this_fiber::yield(); }); modm_faststack modm::Fiber<> fiber1(fiber_function1, modm::fiber::Start::Later); modm_faststack modm::Fiber<> fiber2([](){ fiber_function2(cycles); }, modm::fiber::Start::Later); @@ -71,12 +71,12 @@ extern modm::Fiber<> fiber_pong; extern modm::Fiber<> fiber_ping; modm_faststack modm::Fiber<> fiber_ping([](){ MODM_LOG_INFO << "ping = " << fiber_ping.stack_usage() << modm::endl; - modm::fiber::sleep(1s); + modm::this_fiber::sleep_for(1s); fiber_pong.start(); }, modm::fiber::Start::Later); modm_faststack modm::Fiber<> fiber_pong([](){ MODM_LOG_INFO << "pong = " << fiber_pong.stack_usage() << modm::endl; - modm::fiber::sleep(1s); + modm::this_fiber::sleep_for(1s); fiber_ping.start(); }, modm::fiber::Start::Later); diff --git a/examples/linux/fiber/main.cpp b/examples/linux/fiber/main.cpp index 919bf2574a..a3cdee8d33 100644 --- a/examples/linux/fiber/main.cpp +++ b/examples/linux/fiber/main.cpp @@ -17,7 +17,7 @@ void hello() for(int ii=0; ii<10; ii++) { MODM_LOG_INFO << "Hello "; - modm::fiber::yield(); + modm::this_fiber::yield(); } } @@ -28,7 +28,7 @@ struct Test for(int ii=0; ii<10; ii++) { MODM_LOG_INFO << arg << modm::endl; - modm::fiber::yield(); + modm::this_fiber::yield(); } } } test; diff --git a/examples/rp_pico/fiber/main.cpp b/examples/rp_pico/fiber/main.cpp index e65fd9d1da..8fc2983068 100644 --- a/examples/rp_pico/fiber/main.cpp +++ b/examples/rp_pico/fiber/main.cpp @@ -42,7 +42,7 @@ fiber_function1(CoreData& d) { while (++d.f1counter < cycles) { - modm::fiber::yield(); + modm::this_fiber::yield(); d.total_counter++; } } @@ -52,7 +52,7 @@ fiber_function2(CoreData& d) { while (++d.f2counter < cycles) { - modm::fiber::yield(); + modm::this_fiber::yield(); d.total_counter++; } } diff --git a/examples/stm32f3_discovery/rotation/main.cpp b/examples/stm32f3_discovery/rotation/main.cpp index 4c26d9dbe1..d1aad754f0 100644 --- a/examples/stm32f3_discovery/rotation/main.cpp +++ b/examples/stm32f3_discovery/rotation/main.cpp @@ -69,7 +69,7 @@ modm_faststack modm::Fiber<> fiber_gyro([]() } // repeat every 5 ms - modm::fiber::sleep(5ms); + modm::this_fiber::sleep_for(5ms); } }); @@ -78,7 +78,7 @@ modm_faststack modm::Fiber<> fiber_blinky([]() while (true) { Board::LedSouth::toggle(); - modm::fiber::sleep(1s); + modm::this_fiber::sleep_for(1s); } }); diff --git a/examples/stm32f469_discovery/touchscreen/main.cpp b/examples/stm32f469_discovery/touchscreen/main.cpp index 454ab37062..ad23a7f1a5 100644 --- a/examples/stm32f469_discovery/touchscreen/main.cpp +++ b/examples/stm32f469_discovery/touchscreen/main.cpp @@ -96,7 +96,7 @@ modm_faststack modm::Fiber<> fiber_blinky([]() while(true) { Board::LedGreen::toggle(); - modm::fiber::sleep(20ms); + modm::this_fiber::sleep_for(20ms); } }); diff --git a/src/modm/driver/inertial/bmi088_impl.hpp b/src/modm/driver/inertial/bmi088_impl.hpp index b94dac0604..9f47d75fb1 100644 --- a/src/modm/driver/inertial/bmi088_impl.hpp +++ b/src/modm/driver/inertial/bmi088_impl.hpp @@ -225,7 +225,7 @@ void Bmi088::timerWait() { while (timer_.isArmed()) { - modm::fiber::yield(); + modm::this_fiber::yield(); } } diff --git a/src/modm/driver/inertial/bmi088_transport_impl.hpp b/src/modm/driver/inertial/bmi088_transport_impl.hpp index 8e62894091..8fb3e34e23 100644 --- a/src/modm/driver/inertial/bmi088_transport_impl.hpp +++ b/src/modm/driver/inertial/bmi088_transport_impl.hpp @@ -57,7 +57,7 @@ Bmi088SpiTransport::readRegisters(uint8_t startReg, } while (!this->acquireMaster()) { - modm::fiber::yield(); + modm::this_fiber::yield(); } Cs::reset(); @@ -95,7 +95,7 @@ bool Bmi088SpiTransport::writeRegister(uint8_t reg, uint8_t data) { while (!this->acquireMaster()) { - modm::fiber::yield(); + modm::this_fiber::yield(); } Cs::reset(); diff --git a/src/modm/platform/spi/at90_tiny_mega/spi_master.cpp.in b/src/modm/platform/spi/at90_tiny_mega/spi_master.cpp.in index b93ecdf57d..724ad1e3c3 100644 --- a/src/modm/platform/spi/at90_tiny_mega/spi_master.cpp.in +++ b/src/modm/platform/spi/at90_tiny_mega/spi_master.cpp.in @@ -45,7 +45,7 @@ modm::platform::SpiMaster{{ id }}::transfer(uint8_t data) // start transfer by copying data into register SPDR{{ id }} = data; - do modm::fiber::yield(); + do modm::this_fiber::yield(); while (!(SPSR{{ id }} & (1 << SPIF{{ id }}))); return SPDR{{ id }}; diff --git a/src/modm/platform/spi/at90_tiny_mega_uart/uart_spi_master.cpp.in b/src/modm/platform/spi/at90_tiny_mega_uart/uart_spi_master.cpp.in index e7af684dc8..fe9677929b 100644 --- a/src/modm/platform/spi/at90_tiny_mega_uart/uart_spi_master.cpp.in +++ b/src/modm/platform/spi/at90_tiny_mega_uart/uart_spi_master.cpp.in @@ -62,7 +62,7 @@ modm::platform::UartSpiMaster{{id}}::transfer(uint8_t data) %% if use_fiber // wait for transmit register empty while (!((UCSR{{id}}A & (1 << UDRE{{id}})))) - modm::fiber::yield(); + modm::this_fiber::yield(); %% if not extended if(dataOrder == DataOrder::MsbFirst) { @@ -72,7 +72,7 @@ modm::platform::UartSpiMaster{{id}}::transfer(uint8_t data) UDR{{id}} = data; // wait for receive register not empty - do modm::fiber::yield(); + do modm::this_fiber::yield(); while (!((UCSR{{id}}A & (1 << RXC{{id}})))); data = UDR{{id}}; diff --git a/src/modm/platform/spi/rp/spi_master.cpp.in b/src/modm/platform/spi/rp/spi_master.cpp.in index 622f3c2e74..ca1d026cb9 100644 --- a/src/modm/platform/spi/rp/spi_master.cpp.in +++ b/src/modm/platform/spi/rp/spi_master.cpp.in @@ -30,12 +30,12 @@ modm::platform::SpiMaster{{ id }}::transfer(uint8_t data) { %% if use_fiber // wait for previous transfer to finish - while (txFifoFull()) modm::fiber::yield(); + while (txFifoFull()) modm::this_fiber::yield(); // start transfer by copying data into register write(data); - while (rxFifoEmpty()) modm::fiber::yield(); + while (rxFifoEmpty()) modm::this_fiber::yield(); return read(); %% else diff --git a/src/modm/platform/spi/rp/spi_master_dma_impl.hpp.in b/src/modm/platform/spi/rp/spi_master_dma_impl.hpp.in index 6f6ddb5b3b..96bfbd1c95 100644 --- a/src/modm/platform/spi/rp/spi_master_dma_impl.hpp.in +++ b/src/modm/platform/spi/rp/spi_master_dma_impl.hpp.in @@ -123,16 +123,16 @@ modm::platform::SpiMaster{{ id }}_Dma::transfer( startTransfer(tx, rx, length); while (Dma::TxChannel::isBusy() or (rx and Dma::RxChannel::isBusy())) - modm::fiber::yield(); + modm::this_fiber::yield(); while (!txFifoEmpty() or (rx and !rxFifoEmpty()) or isBusy()) - modm::fiber::yield(); + modm::this_fiber::yield(); if (!rx) { // Drain RX FIFO, then wait for shifting to finish (which // may be *after* TX FIFO drains), then drain RX FIFO again while (!rxFifoEmpty()) read(); - while (isBusy()) modm::fiber::yield(); + while (isBusy()) modm::this_fiber::yield(); // Don't leave overrun flag set spi{{ id }}_hw->icr = SPI_SSPICR_RORIC_BITS; diff --git a/src/modm/platform/spi/sam/spi_master.cpp.in b/src/modm/platform/spi/sam/spi_master.cpp.in index 1c5991ce07..b069d79172 100644 --- a/src/modm/platform/spi/sam/spi_master.cpp.in +++ b/src/modm/platform/spi/sam/spi_master.cpp.in @@ -26,14 +26,14 @@ modm::platform::SpiMaster{{ id }}::transfer(uint8_t data) // wait for previous transfer to finish while (!isTransmitDataRegisterEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // start transfer by copying data into register write(data); // wait for current transfer to finish while(!isReceiveDataRegisterFull()) - modm::fiber::yield(); + modm::this_fiber::yield(); return read(); %% else diff --git a/src/modm/platform/spi/sam_x7x/spi_master.cpp.in b/src/modm/platform/spi/sam_x7x/spi_master.cpp.in index 218c7dc44d..1b17901a16 100644 --- a/src/modm/platform/spi/sam_x7x/spi_master.cpp.in +++ b/src/modm/platform/spi/sam_x7x/spi_master.cpp.in @@ -23,14 +23,14 @@ modm::platform::SpiMaster{{ id }}::transfer(uint8_t data) %% if use_fiber // wait for previous transfer to finish while(!(SpiHal{{ id }}::readStatusFlags() & StatusFlag::TxRegisterEmpty)) - modm::fiber::yield(); + modm::this_fiber::yield(); // start transfer by copying data into register SpiHal{{ id }}::write(data); // wait for current transfer to finish while(!(SpiHal{{ id }}::readStatusFlags() & StatusFlag::RxRegisterFull)) - modm::fiber::yield(); + modm::this_fiber::yield(); // read the received byte SpiHal{{ id }}::read(data); diff --git a/src/modm/platform/spi/stm32/spi_master.cpp.in b/src/modm/platform/spi/stm32/spi_master.cpp.in index 825fc911fe..07baf4b5da 100644 --- a/src/modm/platform/spi/stm32/spi_master.cpp.in +++ b/src/modm/platform/spi/stm32/spi_master.cpp.in @@ -22,14 +22,14 @@ modm::platform::SpiMaster{{ id }}::transfer(uint8_t data) %% if use_fiber // wait for previous transfer to finish while(!SpiHal{{ id }}::isTransmitRegisterEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // start transfer by copying data into register SpiHal{{ id }}::write(data); // wait for current transfer to finish while(!SpiHal{{ id }}::isReceiveRegisterNotEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // read the received byte SpiHal{{ id }}::read(data); diff --git a/src/modm/platform/spi/stm32/spi_master_dma_impl.hpp.in b/src/modm/platform/spi/stm32/spi_master_dma_impl.hpp.in index da2587a585..5d8102a8f9 100644 --- a/src/modm/platform/spi/stm32/spi_master_dma_impl.hpp.in +++ b/src/modm/platform/spi/stm32/spi_master_dma_impl.hpp.in @@ -61,14 +61,14 @@ modm::platform::SpiMaster{{ id }}_Dma::transfer(uint // wait for previous transfer to finish while(!SpiHal{{ id }}::isTransmitRegisterEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // start transfer by copying data into register SpiHal{{ id }}::write(data); // wait for current transfer to finish while(!SpiHal{{ id }}::isReceiveRegisterNotEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // read the received byte SpiHal{{ id }}::read(data); @@ -146,14 +146,14 @@ modm::platform::SpiMaster{{ id }}_Dma::transfer( { if (dmaError) break; else if (not dmaTransmitComplete and not dmaReceiveComplete) - modm::fiber::yield(); + modm::this_fiber::yield(); %% if "fifo" in features else if (SpiHal{{ id }}::getInterruptFlags() & (SpiBase::InterruptFlag::Busy | SpiBase::InterruptFlag::FifoTxLevel | SpiBase::InterruptFlag::FifoRxLevel)) %% else else if (SpiHal{{ id }}::getInterruptFlags() & SpiBase::InterruptFlag::Busy) %% endif - modm::fiber::yield(); + modm::this_fiber::yield(); else break; } diff --git a/src/modm/platform/spi/stm32_uart/uart_spi_master.cpp.in b/src/modm/platform/spi/stm32_uart/uart_spi_master.cpp.in index 282303cd39..f03238143c 100644 --- a/src/modm/platform/spi/stm32_uart/uart_spi_master.cpp.in +++ b/src/modm/platform/spi/stm32_uart/uart_spi_master.cpp.in @@ -31,7 +31,7 @@ modm::platform::UartSpiMaster{{ id }}::transfer(uint8_t data) %% if use_fiber // wait for previous transfer to finish while (!UsartHal{{ id }}::isTransmitRegisterEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); // start transfer by copying data into register if(dataOrder == DataOrder::MsbFirst) @@ -40,7 +40,7 @@ modm::platform::UartSpiMaster{{ id }}::transfer(uint8_t data) // wait for current transfer to finish while (!UsartHal{{ id }}::isReceiveRegisterNotEmpty()) - modm::fiber::yield(); + modm::this_fiber::yield(); UsartHal{{ id }}::read(data); diff --git a/src/modm/platform/spi/stm32h7/spi_master.cpp.in b/src/modm/platform/spi/stm32h7/spi_master.cpp.in index 02b498a617..b7275e86c6 100644 --- a/src/modm/platform/spi/stm32h7/spi_master.cpp.in +++ b/src/modm/platform/spi/stm32h7/spi_master.cpp.in @@ -25,12 +25,12 @@ SpiMaster{{ id }}::transfer(uint8_t data) { %% if use_fiber while (Hal::isTxFifoFull()) - modm::fiber::yield(); + modm::this_fiber::yield(); Hal::write(data); while (!Hal::isRxDataAvailable()) - modm::fiber::yield(); + modm::this_fiber::yield(); return Hal::read(); %% else @@ -83,7 +83,7 @@ SpiMaster{{ id }}::transfer( ++rxIndex; } if (rxIndex < length) { - modm::fiber::yield(); + modm::this_fiber::yield(); } } %% else diff --git a/src/modm/platform/spi/stm32h7/spi_master_dma_impl.hpp.in b/src/modm/platform/spi/stm32h7/spi_master_dma_impl.hpp.in index a159b8f3b2..92039310b4 100644 --- a/src/modm/platform/spi/stm32h7/spi_master_dma_impl.hpp.in +++ b/src/modm/platform/spi/stm32h7/spi_master_dma_impl.hpp.in @@ -66,7 +66,7 @@ SpiMaster{{ id }}_Dma::transfer(uint8_t data) // wait for transfer to complete while (!Hal::isTransferCompleted()) - modm::fiber::yield(); + modm::this_fiber::yield(); data = SpiHal{{ id }}::read(); finishTransfer(); @@ -174,7 +174,7 @@ SpiMaster{{ id }}_Dma::transfer( break; } } - modm::fiber::yield(); + modm::this_fiber::yield(); } finishTransfer(); %% else diff --git a/src/modm/processing/fiber/functions.hpp b/src/modm/processing/fiber/functions.hpp index bef9c5a73f..f737e76f54 100644 --- a/src/modm/processing/fiber/functions.hpp +++ b/src/modm/processing/fiber/functions.hpp @@ -16,7 +16,7 @@ #include "scheduler.hpp" #include -namespace modm::fiber +namespace modm::this_fiber { /// @ingroup modm_processing_fiber @@ -39,7 +39,7 @@ namespace modm::fiber inline void yield() { - Scheduler::instance().yield(); + modm::fiber::Scheduler::instance().yield(); } /** @@ -53,7 +53,7 @@ yield() */ template< typename Rep, typename Period > void -sleep(std::chrono::duration interval) +sleep_for(std::chrono::duration interval) { // Only choose the microsecond clock if necessary using TimeoutType = std::conditional_t< @@ -70,4 +70,21 @@ sleep(std::chrono::duration interval) /// @} -} // namespace modm::fiber +} // namespace modm::this_fiber + +/// @cond +// DEPRECATE: 2025q2 +namespace modm::fiber +{ + +modm_deprecated("Use `modm::this_fiber::yield()` instead!") +void inline yield() +{ this_fiber::yield(); } + +template< class Rep, class Period > +modm_deprecated("Use `modm::this_fiber::sleep_for()` instead!") +void sleep(std::chrono::duration sleep_duration) +{ this_fiber::sleep_for(sleep_duration); } + +} +/// @endcond diff --git a/src/modm/processing/fiber/module.md b/src/modm/processing/fiber/module.md index c114dff869..90b13b5f93 100644 --- a/src/modm/processing/fiber/module.md +++ b/src/modm/processing/fiber/module.md @@ -7,11 +7,11 @@ simple round-robin scheduler. Here is a minimal example that blinks an LED: modm::Fiber<> fiber([]() { Board::LedBlue::setOutput(); - modm::fiber::yield(); + modm::this_fiber::yield(); while(true) { Board::LedBlue::toggle(); - modm::fiber::sleep(1s); + modm::this_fiber::sleep_for(1s); } }); int main(void) @@ -80,7 +80,7 @@ modm::Fiber<> fiber(function, false); // fiber2 is automatically executing modm::Fiber<> fiber2([&]() { - modm::fiber::sleep(1s); + modm::this_fiber::sleep_for(1s); fiber.start(); }); modm::fiber::Scheduler::run(); @@ -194,7 +194,7 @@ registers contain the watermark value. Fibers are implemented by saving callee registers to the current stack, then switching to a new stack and restoring callee registers from this stack. -The static `modm::fiber::yield()` function wraps this functionality in a +The static `modm::this_fiber::yield()` function wraps this functionality in a transparent way. ### AVR diff --git a/src/modm/processing/fiber/scheduler.hpp.in b/src/modm/processing/fiber/scheduler.hpp.in index 1e6747753d..c379020d34 100644 --- a/src/modm/processing/fiber/scheduler.hpp.in +++ b/src/modm/processing/fiber/scheduler.hpp.in @@ -13,12 +13,15 @@ #pragma once -#include "fiber.hpp" +#include "task.hpp" #include %% if multicore #include %% endif +// forward declaration +namespace modm::this_fiber { void yield(); } + namespace modm::fiber { @@ -33,7 +36,7 @@ namespace modm::fiber class Scheduler { friend class Task; - friend void yield(); + friend void modm::this_fiber::yield(); Scheduler(const Scheduler&) = delete; Scheduler& operator=(const Scheduler&) = delete; diff --git a/src/modm/processing/protothread/macros_fiber.hpp b/src/modm/processing/protothread/macros_fiber.hpp index acd5cd35d7..df61ffe2ea 100644 --- a/src/modm/processing/protothread/macros_fiber.hpp +++ b/src/modm/processing/protothread/macros_fiber.hpp @@ -39,7 +39,7 @@ /// Yield protothread till next call to its run(). /// \hideinitializer #define PT_YIELD() \ - modm::fiber::yield() + modm::this_fiber::yield() /// Cause protothread to wait **while** given condition is true. /// \hideinitializer diff --git a/src/modm/processing/protothread/module.md b/src/modm/processing/protothread/module.md index 8db6ef0ace..e90b182139 100644 --- a/src/modm/processing/protothread/module.md +++ b/src/modm/processing/protothread/module.md @@ -83,11 +83,11 @@ option, which replaces the preprocessor macros and C++ implementations of this and the `modm:processing:resumable` module with a fiber version. Specifically, the `PT_*` and `RF_*` macros are now forwarding their arguments -unmodified and instead relying on `modm::fiber::yield()` for context switching: +unmodified and instead relying on `modm::this_fiber::yield()` for context switching: ```cpp -#define PT_YIELD() modm::fiber::yield() -#define PT_WAIT_WHILE(cond) while(cond) { modm::fiber::yield(); } +#define PT_YIELD() modm::this_fiber::yield() +#define PT_WAIT_WHILE(cond) while(cond) { modm::this_fiber::yield(); } #define PT_CALL(func) func ``` diff --git a/src/modm/processing/protothread/protothread_fiber.hpp b/src/modm/processing/protothread/protothread_fiber.hpp index 9c13df71ab..816b27f4be 100644 --- a/src/modm/processing/protothread/protothread_fiber.hpp +++ b/src/modm/processing/protothread/protothread_fiber.hpp @@ -30,7 +30,7 @@ class Protothread : public modm::Fiber< MODM_PROTOTHREAD_STACK_SIZE > { public: Protothread(modm::fiber::Start start=modm::fiber::Start::Now) - : Fiber([this](){ while(update()) modm::fiber::yield(); }, start) + : Fiber([this](){ while(update()) modm::this_fiber::yield(); }, start) {} void restart() { this->start(); } diff --git a/src/modm/processing/resumable/macros_fiber.hpp b/src/modm/processing/resumable/macros_fiber.hpp index a867bbb2ec..60dde2c981 100644 --- a/src/modm/processing/resumable/macros_fiber.hpp +++ b/src/modm/processing/resumable/macros_fiber.hpp @@ -52,7 +52,7 @@ /// Yield resumable function until next invocation. /// @hideinitializer #define RF_YIELD() \ - modm::fiber::yield() + modm::this_fiber::yield() /// Cause resumable function to wait until given child protothread completes. /// @hideinitializer diff --git a/src/modm/processing/resumable/module.md b/src/modm/processing/resumable/module.md index 300ae5e176..e815774716 100644 --- a/src/modm/processing/resumable/module.md +++ b/src/modm/processing/resumable/module.md @@ -164,17 +164,17 @@ preprocessor macros and C++ implementations of this and the `modm:processing:protothreads` module with a fiber version. Specifically, the `PT_*` and `RF_*` macros are now forwarding their arguments -unmodified and instead relying on `modm::fiber::yield()` for context switching: +unmodified and instead relying on `modm::this_fiber::yield()` for context switching: ```cpp -#define RF_YIELD() modm::fiber::yield() -#define RF_WAIT_WHILE(cond) while(cond) { modm::fiber::yield(); } +#define RF_YIELD() modm::this_fiber::yield() +#define RF_WAIT_WHILE(cond) while(cond) { modm::this_fiber::yield(); } #define RF_CALL(func) func #define RF_RETURN(value) return value ``` You may call `RF_CALL_BLOCKING(resumable)` outside a fiber context, in which -case the `modm::fiber::yield()` will return immediately, which is the same +case the `modm::this_fiber::yield()` will return immediately, which is the same behavior as before. However, the `modm::ResumableResult`, `modm::Resumable`, and `modm::NestedResumable` diff --git a/test/modm/processing/fiber/fiber_test.cpp b/test/modm/processing/fiber/fiber_test.cpp index fb760b6ece..97f110d9fb 100644 --- a/test/modm/processing/fiber/fiber_test.cpp +++ b/test/modm/processing/fiber/fiber_test.cpp @@ -44,7 +44,7 @@ void f1() { ADD_STATE(F1_START); - modm::fiber::yield(); + modm::this_fiber::yield(); ADD_STATE(F1_END); } @@ -52,7 +52,7 @@ void f2() { ADD_STATE(F2_START); - modm::fiber::yield(); + modm::this_fiber::yield(); ADD_STATE(F2_END); } @@ -88,7 +88,7 @@ __attribute__((noinline)) void subroutine() { ADD_STATE(SUBROUTINE_START); - modm::fiber::yield(); + modm::this_fiber::yield(); ADD_STATE(SUBROUTINE_END); }