Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Dealing with multiple threads #227

Open
drahnr opened this issue Sep 29, 2017 · 1 comment
Open

Dealing with multiple threads #227

drahnr opened this issue Sep 29, 2017 · 1 comment

Comments

@drahnr
Copy link

drahnr commented Sep 29, 2017

How to deal with multiple threads? Especially scoped thread pools are of interest to me.

So far all attempts of implementation ended with

error[E0277]: the trait bound `std::error::Error + 'static: std::marker::Send` is not satisfied
  --> src/main.rs:35:5
   |
35 | /     error_chain!{
36 | |
37 | |         foreign_links {
38 | |             Mqttc(::mqttc::Error);
...  |
53 | |         }
54 | |     }
   | |_____^ `std::error::Error + 'static` cannot be sent between threads safely
   |
   = help: the trait `std::marker::Send` is not implemented for `std::error::Error + 'static`
   = note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::error::Error + 'static>`
   = note: required because it appears within the type `std::boxed::Box<std::error::Error + 'static>`
   = note: required because it appears within the type `mqttc::netopt::Error`
   = note: required because it appears within the type `mqttc::Error`
   = note: required because it appears within the type `errors::ErrorKind`
   = note: required because it appears within the type `errors::Error`
   = note: required by `error_chain::ChainedError`
   = note: this error originates in a macro outside of the current crate

error: aborting due to previous error(s)

error: Could not compile `mqttblaster`.

Not there is no transfer between the threads. I would like to use one "chain" per thread.

There is nothing in the examples that would show how to deal with this use case.

I also posted this question here: https://stackoverflow.com/questions/46491293/multithreaded-application-fails-to-compile-with-error-chain?noredirect=1#comment79937075_46491293

@Yamakaky
Copy link
Contributor

Yamakaky commented Sep 29, 2017

I think it's because mqttc::Error doesn't impl Send, which error-chain requires.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants