Core: thread allocation shortcut (#2007)
* Core: thread alloc+set shortcut * Apps: use thread allocation shortcut * Mark some service threads as services * Init BT as soon as possible Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -45,11 +45,9 @@ void platformDisableIrqCallback() {
|
||||
|
||||
void platformSetIrqCallback(PlatformIrqCallback callback) {
|
||||
rfal_platform.callback = callback;
|
||||
rfal_platform.thread = furi_thread_alloc();
|
||||
|
||||
furi_thread_set_name(rfal_platform.thread, "RfalIrqDriver");
|
||||
furi_thread_set_callback(rfal_platform.thread, rfal_platform_irq_thread);
|
||||
furi_thread_set_stack_size(rfal_platform.thread, 1024);
|
||||
rfal_platform.thread =
|
||||
furi_thread_alloc_ex("RfalIrqDriver", 1024, rfal_platform_irq_thread, NULL);
|
||||
furi_thread_mark_as_service(rfal_platform.thread);
|
||||
furi_thread_set_priority(rfal_platform.thread, FuriThreadPriorityIsr);
|
||||
furi_thread_start(rfal_platform.thread);
|
||||
|
||||
|
||||
@@ -104,11 +104,8 @@ FuriThread* flipper_application_spawn(FlipperApplication* app, void* args) {
|
||||
const FlipperApplicationManifest* manifest = flipper_application_get_manifest(app);
|
||||
furi_check(manifest->stack_size > 0);
|
||||
|
||||
app->thread = furi_thread_alloc();
|
||||
furi_thread_set_stack_size(app->thread, manifest->stack_size);
|
||||
furi_thread_set_name(app->thread, manifest->name);
|
||||
furi_thread_set_callback(app->thread, flipper_application_thread);
|
||||
furi_thread_set_context(app->thread, args);
|
||||
app->thread = furi_thread_alloc_ex(
|
||||
manifest->name, manifest->stack_size, flipper_application_thread, args);
|
||||
|
||||
return app->thread;
|
||||
}
|
||||
|
||||
@@ -223,10 +223,7 @@ void infrared_worker_rx_set_received_signal_callback(
|
||||
InfraredWorker* infrared_worker_alloc() {
|
||||
InfraredWorker* instance = malloc(sizeof(InfraredWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "InfraredWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
instance->thread = furi_thread_alloc_ex("InfraredWorker", 2048, NULL, instance);
|
||||
|
||||
size_t buffer_size =
|
||||
MAX(sizeof(InfraredWorkerTiming) * (MAX_TIMINGS_AMOUNT + 1),
|
||||
|
||||
@@ -61,10 +61,7 @@ static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context);
|
||||
LFRFIDRawWorker* lfrfid_raw_worker_alloc() {
|
||||
LFRFIDRawWorker* worker = malloc(sizeof(LFRFIDRawWorker));
|
||||
|
||||
worker->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(worker->thread, "lfrfid_raw_worker");
|
||||
furi_thread_set_context(worker->thread, worker);
|
||||
furi_thread_set_stack_size(worker->thread, 2048);
|
||||
worker->thread = furi_thread_alloc_ex("LfrfidRawWorker", 2048, NULL, worker);
|
||||
|
||||
worker->events = furi_event_flag_alloc(NULL);
|
||||
|
||||
|
||||
@@ -29,11 +29,7 @@ LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) {
|
||||
worker->raw_filename = NULL;
|
||||
worker->mode_storage = NULL;
|
||||
|
||||
worker->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(worker->thread, "lfrfid_worker");
|
||||
furi_thread_set_callback(worker->thread, lfrfid_worker_thread);
|
||||
furi_thread_set_context(worker->thread, worker);
|
||||
furi_thread_set_stack_size(worker->thread, 2048);
|
||||
worker->thread = furi_thread_alloc_ex("LfrfidWorker", 2048, lfrfid_worker_thread, worker);
|
||||
|
||||
worker->protocols = dict;
|
||||
|
||||
|
||||
@@ -104,11 +104,8 @@ ReaderAnalyzer* reader_analyzer_alloc() {
|
||||
instance->stream =
|
||||
furi_stream_buffer_alloc(READER_ANALYZER_MAX_BUFF_SIZE, sizeof(ReaderAnalyzerHeader));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "ReaderAnalyzerWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_callback(instance->thread, reader_analyzer_thread);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
instance->thread =
|
||||
furi_thread_alloc_ex("ReaderAnalyzerWorker", 2048, reader_analyzer_thread, instance);
|
||||
furi_thread_set_priority(instance->thread, FuriThreadPriorityLow);
|
||||
|
||||
return instance;
|
||||
|
||||
@@ -12,11 +12,7 @@ NfcWorker* nfc_worker_alloc() {
|
||||
NfcWorker* nfc_worker = malloc(sizeof(NfcWorker));
|
||||
|
||||
// Worker thread attributes
|
||||
nfc_worker->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(nfc_worker->thread, "NfcWorker");
|
||||
furi_thread_set_stack_size(nfc_worker->thread, 8192);
|
||||
furi_thread_set_callback(nfc_worker->thread, nfc_worker_task);
|
||||
furi_thread_set_context(nfc_worker->thread, nfc_worker);
|
||||
nfc_worker->thread = furi_thread_alloc_ex("NfcWorker", 8192, nfc_worker_task, nfc_worker);
|
||||
|
||||
nfc_worker->callback = NULL;
|
||||
nfc_worker->context = NULL;
|
||||
|
||||
@@ -37,11 +37,7 @@ iButtonWorker* ibutton_worker_alloc() {
|
||||
worker->emulate_cb = NULL;
|
||||
worker->cb_ctx = NULL;
|
||||
|
||||
worker->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(worker->thread, "ibutton_worker");
|
||||
furi_thread_set_callback(worker->thread, ibutton_worker_thread);
|
||||
furi_thread_set_context(worker->thread, worker);
|
||||
furi_thread_set_stack_size(worker->thread, 2048);
|
||||
worker->thread = furi_thread_alloc_ex("iButtonWorker", 2048, ibutton_worker_thread, worker);
|
||||
|
||||
worker->protocols = protocol_dict_alloc(ibutton_protocols, iButtonProtocolMax);
|
||||
|
||||
|
||||
@@ -174,11 +174,8 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
||||
SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc() {
|
||||
SubGhzFileEncoderWorker* instance = malloc(sizeof(SubGhzFileEncoderWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "SubGhzFEWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subghz_file_encoder_worker_thread);
|
||||
instance->thread =
|
||||
furi_thread_alloc_ex("SubGhzFEWorker", 2048, subghz_file_encoder_worker_thread, instance);
|
||||
instance->stream = furi_stream_buffer_alloc(sizeof(int32_t) * 2048, sizeof(int32_t));
|
||||
|
||||
instance->storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
@@ -201,11 +201,8 @@ static int32_t subghz_tx_rx_worker_thread(void* context) {
|
||||
SubGhzTxRxWorker* subghz_tx_rx_worker_alloc() {
|
||||
SubGhzTxRxWorker* instance = malloc(sizeof(SubGhzTxRxWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "SubGhzTxRxWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subghz_tx_rx_worker_thread);
|
||||
instance->thread =
|
||||
furi_thread_alloc_ex("SubGhzTxRxWorker", 2048, subghz_tx_rx_worker_thread, instance);
|
||||
instance->stream_tx =
|
||||
furi_stream_buffer_alloc(sizeof(uint8_t) * SUBGHZ_TXRX_WORKER_BUF_SIZE, sizeof(uint8_t));
|
||||
instance->stream_rx =
|
||||
|
||||
@@ -88,11 +88,8 @@ static int32_t subghz_worker_thread_callback(void* context) {
|
||||
SubGhzWorker* subghz_worker_alloc() {
|
||||
SubGhzWorker* instance = malloc(sizeof(SubGhzWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "SubGhzWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subghz_worker_thread_callback);
|
||||
instance->thread =
|
||||
furi_thread_alloc_ex("SubGhzWorker", 2048, subghz_worker_thread_callback, instance);
|
||||
|
||||
instance->stream =
|
||||
furi_stream_buffer_alloc(sizeof(LevelDuration) * 4096, sizeof(LevelDuration));
|
||||
|
||||
Reference in New Issue
Block a user