Have you tried using type Arc<Mutex<Engine>> instead of Arc<Mutex<EngineWrapper>>? I don't understand why you need EngineWrapper, since you can access Engine via an Arc<Mutex<..>> mutably from all threads.
If holding an exclusive lock on the engine causes too much contention, perhaps you can use Arc<RwLock<Engine>> instead. When you don't need mutable/exclusive access, get a read lock instead of a write lock.
I would try removing the use of unsafe to see if that's the problem. If you don't use EngineWrapper, can you avoid unsafe entirely?
I am depending on a c++ library for the engine. So I can't really remove unsafe.
I will try wrapping Engine in Arc<Mutex<..>> and tell if it works or not
Failed to extract `Data<Engine>` for `get_response` handler. For the Data extractor to work correctly, wrap the data with `Data::new()` and pass it to `App::app_data()`. Ensure that types align in both the set and retrieve calls.
My current server side code
let engine = Engine::new().unwrap();
let data = Data::new(Arc::new(Mutex::new(engine)));
let server = HttpServer::new(move || {
App::new()
.app_data(data.clone())
.service(get_response)
})
.listen(listener)?
.run();
This sounds like the extractor is not set up properly, which is an actix-web usage issue rather than a raw pointer issue. I have not used actix-web so I won't be able to help with that. Sorry for the confusion.
In order for someone to guide you in the debugging process, you'll need to share a lot more, for example:
The server log entries that you say prove that the request was processed, and your reasoning for why you believe the request was fully processed and the response was sent.
All the code you've written that is involved in creating the response message. The best thing is to share all your code by linking to the repo.
Be sure to share the current logging output and code, and the symptoms you're seeing for that particular code and logging output.