lock print

This commit is contained in:
Kizarm 2024-08-17 20:59:36 +02:00
parent dc1a63fbb0
commit 273a477a37

View file

@ -1,6 +1,10 @@
#include <cstdio> #include <cstdio>
#include <mutex>
#include "utils.h" #include "utils.h"
static std::mutex Mutex;
void print_morse_table (const TABLE<unsigned char, 64> & tab) { void print_morse_table (const TABLE<unsigned char, 64> & tab) {
Mutex.lock();
int n = 0; int n = 0;
printf("static const unsigned char compressed_table [] = {"); printf("static const unsigned char compressed_table [] = {");
for (auto & e: tab) { for (auto & e: tab) {
@ -9,8 +13,10 @@ void print_morse_table (const TABLE<unsigned char, 64> & tab) {
n++; n++;
} }
printf("\n};\n"); printf("\n};\n");
Mutex.unlock();
} }
void print_sinus_table (const TABLE<unsigned short, 256> & tab) { void print_sinus_table (const TABLE<unsigned short, 256> & tab) {
Mutex.lock();
int n = 0; int n = 0;
printf("static const uint16_t sin_tab [] = {"); printf("static const uint16_t sin_tab [] = {");
for (auto & e: tab) { for (auto & e: tab) {
@ -19,4 +25,5 @@ void print_sinus_table (const TABLE<unsigned short, 256> & tab) {
n++; n++;
} }
printf("\n};\n"); printf("\n};\n");
Mutex.unlock();
} }