wip: stop sharing the inbox across threads

This commit is contained in:
dignifiedquire
2019-11-11 17:55:50 +01:00
parent 50aa68e047
commit 0e953d18d0
9 changed files with 301 additions and 295 deletions

View File

@@ -496,10 +496,12 @@ pub unsafe fn dc_cmdline(context: &Context, line: &str) -> Result<(), failure::E
println!("{:#?}", context.get_info());
}
"interrupt" => {
interrupt_imap_idle(context);
// interrupt_imap_idle(context);
unimplemented!()
}
"maybenetwork" => {
maybe_network(context);
// maybe_network(context);
unimplemented!()
}
"housekeeping" => {
sql::housekeeping(context);

View File

@@ -149,12 +149,14 @@ fn start_threads(c: Arc<RwLock<Context>>) {
let ctx = c.clone();
let handle_imap = std::thread::spawn(move || loop {
let mut inbox = ctx.read().unwrap().create_inbox();
while_running!({
perform_imap_jobs(&ctx.read().unwrap());
perform_imap_fetch(&ctx.read().unwrap());
perform_imap_jobs(&ctx.read().unwrap(), &mut inbox);
perform_imap_fetch(&ctx.read().unwrap(), &mut inbox);
while_running!({
let context = ctx.read().unwrap();
perform_imap_idle(&context);
perform_imap_idle(&context, &mut inbox);
});
});
});
@@ -202,7 +204,7 @@ fn stop_threads(context: &Context) {
println!("Stopping threads");
IS_RUNNING.store(false, Ordering::Relaxed);
interrupt_imap_idle(context);
// interrupt_imap_idle(context);
interrupt_mvbox_idle(context);
interrupt_sentbox_idle(context);
interrupt_smtp_idle(context);
@@ -457,7 +459,8 @@ unsafe fn handle_cmd(line: &str, ctx: Arc<RwLock<Context>>) -> Result<ExitResult
if HANDLE.clone().lock().unwrap().is_some() {
println!("imap-jobs are already running in a thread.");
} else {
perform_imap_jobs(&ctx.read().unwrap());
// perform_imap_jobs(&ctx.read().unwrap());
unimplemented!()
}
}
"configure" => {

View File

@@ -49,13 +49,15 @@ fn main() {
let ctx1 = ctx.clone();
let r1 = running.clone();
let t1 = thread::spawn(move || {
let mut inbox = ctx1.create_inbox();
while *r1.read().unwrap() {
perform_imap_jobs(&ctx1);
perform_imap_jobs(&ctx1, &mut inbox);
if *r1.read().unwrap() {
perform_imap_fetch(&ctx1);
perform_imap_fetch(&ctx1, &mut inbox);
if *r1.read().unwrap() {
perform_imap_idle(&ctx1);
perform_imap_idle(&ctx1, &mut inbox);
}
}
}
@@ -113,7 +115,7 @@ fn main() {
println!("stopping threads");
*running.clone().write().unwrap() = false;
deltachat::job::interrupt_imap_idle(&ctx);
// not needed anymore I believe. deltachat::job::interrupt_imap_idle(&ctx);
deltachat::job::interrupt_smtp_idle(&ctx);
println!("joining");