MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / start

Method start

TactilityFreeRtos/Include/Tactility/Thread.h:172–221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170 }
171
172 void start() {
173 mutex.lock();
174 assert(mainFunction);
175 assert(state == State::Stopped);
176 assert(stackSize > 0 && stackSize < (UINT16_MAX * sizeof(StackType_t)));
177 mutex.unlock();
178
179 setState(State::Starting);
180
181 mutex.lock();
182 uint32_t stack_depth = stackSize / sizeof(StackType_t);
183 mutex.unlock();
184
185 BaseType_t result;
186 if (affinity != -1) {
187#ifdef ESP_PLATFORM
188 result = xTaskCreatePinnedToCore(
189 mainBody,
190 name.c_str(),
191 stack_depth,
192 this,
193 static_cast<UBaseType_t>(priority),
194 &taskHandle,
195 affinity
196 );
197#else
198 // Pinned tasks are not supported by current FreeRTOS platform - creating regular one
199 result = xTaskCreate(
200 mainBody,
201 name.c_str(),
202 stack_depth,
203 this,
204 static_cast<UBaseType_t>(priority),
205 &taskHandle
206 );
207#endif
208 } else {
209 result = xTaskCreate(
210 mainBody,
211 name.c_str(),
212 stack_depth,
213 this,
214 static_cast<UBaseType_t>(priority),
215 &taskHandle
216 );
217 }
218
219 assert(result == pdPASS);
220 assert(taskHandle != nullptr || getState() == State::Stopped);
221 }
222
223 /**
224 * @warning If this blocks forever, it might be because of the Thread, but it could also be because another task is blocking the CPU.

Callers

nothing calls this directly

Calls 3

getStateFunction · 0.85
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected