Hi ! In order to access external variables in a thread, we must use the move closure with the move keyword in the thread creation. In example, these 2 lines will define and create a mutable variable and then a new thread where we can access the var. let mut new_var = “hey!”; let handle…… Continue reading #Rust ๐ฆ – Accesing external vars in threads ๐งต
Tag: MultiThread
#Rust ๐ฆ – Working with threads ๐งต and joining thread handles
Hi ! Let’s take a look at the following code. The main thread will run a loop for ~5 seconds, displaying a message every 1 second. The 2nd thread with display a message, wait 5 seconds and display a 2nd message. https://gist.github.com/elbruno/5b116361ed0a9931b52ae59f678e2516 The code output shows that the app is closed before finishing the execution…… Continue reading #Rust ๐ฆ – Working with threads ๐งต and joining thread handles
#Rust ๐ฆ- Working with threads ๐งต (concurrency)
Hi ! Working with threads is usually an interesting (challenging) task, when we program in low level languages. I love how easy is to do this in C# or Python, however, multi-threading in C++ is … a super fun moment. So, the idea behind this is to have sections of code in our application runing…… Continue reading #Rust ๐ฆ- Working with threads ๐งต (concurrency)
#Python – #FastAPI Webserver sharing information from values in a different thread
Hi ! After my yesterday post using Flask, I was sure that a FastAPI version will be needed, so here it goes: I have a common scenario which involves: A sensor collecting informationA web-server publishing the sensor information Read my previous posts to understand why I think this is the simple way to solve this:…… Continue reading #Python – #FastAPI Webserver sharing information from values in a different thread
#Python – Flask Webserver sharing information from values in a different thread
Hi ! I have a common scenario which involves: A sensor collecting informationA web-server publishing the sensor information This is simple, however the sensor does not support constants requests, and it may return a “too many requests” response when called directly. The idea to get the sensor information directly in the web-request was not valid…… Continue reading #Python – Flask Webserver sharing information from values in a different thread