int imap_get_folder_list(struct imap_server *server, imap_get_folder_list_callback_t callback) { struct imap_get_folder_list_entry_msg msg; msg.server = server; msg.callback = callback; return thread_start(THREAD_FUNCTION(&imap_get_folder_list_entry),&msg); }
int imap_submit_folder_list(struct imap_server *server, struct string_list *list) { struct imap_submit_folder_list_entry_msg msg; msg.server = server; msg.list = list; return thread_start(THREAD_FUNCTION(&imap_submit_folder_list_entry),&msg); }
LispRef eul_thr_create(LispRef thr, LispRef args) { int arity = 0; PCR_Th_T *thr_handle; RegisterRef tame_regs; LispRef fn; PCR_Th_ML *thr_join_mt; /* Ensure initial function is a lambda function */ fn = THREAD_FUNCTION(thr); if(!eul_is_lambda(fn)) if(!eul_is_gf(fn)) { printf("\n*** ERROR [system]: bad foreign function in-call\n"); fprint_ref(stdout,fn); exit(-1); } else { /* This is a generic function, and can't be directly executed. * therefore, use the discriminator of this function */ fn = GF_DISC_FN(fn); } /* Setup registers */ tame_regs = gc_malloc(sizeof(RegisterSet)); INITIALISE_REGISTER_SET(tame_regs); tame_regs->reg_value_stack->sp = tame_regs->reg_value_stack->base; tame_regs->reg_context_stack->sp = tame_regs->reg_context_stack->base; tame_regs->reg_current_cv = (Instruction *) LAMBDA_CODE(fn); tame_regs->reg_pc = tame_regs->reg_current_cv; tame_regs->reg_env = LAMBDA_ENV(fn); tame_regs->reg_next_methods = eul_nil; /* Push arguments on to stack and count arity */ while(args != eul_nil) { EXTERNAL_PUSHVAL1(eul_car(args)); args = eul_cdr(args); arity++; } tame_regs->reg_arg_count = arity; THREAD_REGISTERS(thr) = (LispRef) tame_regs; thr_join_mt = (PCR_Th_ML *) gc_malloc(sizeof(PCR_Th_ML)); PCR_Th_ML_Init(thr_join_mt); THREAD_RETURN_MUTEX(thr) = (LispRef) thr_join_mt; /* Create the thread in a suspended state */ THREAD_HANDLE(thr) = (LispRef) PCR_Th_Fork((void (*) (void *)) eul_thr_interpret, thr); return thr; }
/** * The function creates the IMAP thread. It doesn't start the thread * if it is already started. * * @return whether the thread has been started. */ static int imap_start_thread(void) { if (imap_thread) return 1; imap_thread = thread_add(IMAP_THREAD_NAME, THREAD_FUNCTION(&imap_thread_entry),NULL); return !!imap_thread; }