mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
a round of renaming towards dc_io_* methods for start/stop/io scheduling
This commit is contained in:
@@ -11,12 +11,11 @@ APIs:
|
||||
dc_configure # note: dc_start_jobs() is NOT allowed to run concurrently
|
||||
dc_imex NEVER goes through the job system
|
||||
dc_imex import_backup needs to ensure dc_stop_jobs()
|
||||
dc_jobs_are_running() # tell if we are in start/stop-jobs state
|
||||
|
||||
dc_context_run # start async scheduler
|
||||
-> dc_start_jobs
|
||||
dc_context_shutdown # Stop async scheduler (after return no async-task runs)
|
||||
-> dc_stop_jobs
|
||||
dc_io_start # start smtp/imap and job handling subsystems
|
||||
dc_io_stop # stop smtp/imap and job handling subsystems
|
||||
dc_io_status # return 1 if smtp/imap/jobs susbystem is running
|
||||
|
||||
dc_close # FFI only
|
||||
-> can be dropped
|
||||
dc_context_unref
|
||||
|
||||
@@ -583,16 +583,32 @@ int dc_is_configured (const dc_context_t* context);
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Document
|
||||
* Start job and IMAP/SMTP tasks.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as created by dc_context_new().
|
||||
* @return None
|
||||
*/
|
||||
void dc_context_run (dc_context_t* context);
|
||||
|
||||
int dc_is_running (const dc_context_t* context);
|
||||
void dc_io_start (dc_context_t* context);
|
||||
|
||||
/**
|
||||
* TODO: Document
|
||||
* Check if IO (SMTP/IMAP/Jobs) has been started.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as created by dc_context_new().
|
||||
* @return 1=IO is running;
|
||||
* 0=IO is not running.
|
||||
*/
|
||||
void dc_context_shutdown(dc_context_t* context);
|
||||
int dc_io_status(const dc_context_t* context);
|
||||
|
||||
/**
|
||||
* Stop job and IMAP/SMTP tasks and return when they are finished.
|
||||
*
|
||||
* @memberof dc_context_t
|
||||
* @param context The context object as created by dc_context_new().
|
||||
* @return None
|
||||
*/
|
||||
void dc_io_stop(dc_context_t* context);
|
||||
|
||||
/**
|
||||
* This function can be called whenever there is a hint
|
||||
|
||||
@@ -481,7 +481,7 @@ pub unsafe extern "C" fn dc_is_configured(context: *mut dc_context_t) -> libc::c
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_context_run(context: *mut dc_context_t) {
|
||||
pub unsafe extern "C" fn dc_io_start(context: *mut dc_context_t) {
|
||||
if context.is_null() {
|
||||
return;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ pub unsafe extern "C" fn dc_context_run(context: *mut dc_context_t) {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_is_running(context: *mut dc_context_t) -> libc::c_int {
|
||||
pub unsafe extern "C" fn dc_io_status(context: *mut dc_context_t) -> libc::c_int {
|
||||
if context.is_null() {
|
||||
return 0;
|
||||
}
|
||||
@@ -665,7 +665,7 @@ pub unsafe extern "C" fn dc_get_next_event(context: *mut dc_context_t) -> *mut d
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn dc_context_shutdown(context: *mut dc_context_t) {
|
||||
pub unsafe extern "C" fn dc_io_stop(context: *mut dc_context_t) {
|
||||
if context.is_null() {
|
||||
eprintln!("ignoring careless call to dc_shutdown()");
|
||||
return;
|
||||
|
||||
@@ -4,4 +4,4 @@ from deltachat.capi import ffi, lib
|
||||
|
||||
if __name__ == "__main__":
|
||||
ctx = capi.lib.dc_context_new(ffi.NULL, ffi.NULL)
|
||||
lib.dc_context_shutdown(ctx)
|
||||
lib.dc_io_stop(ctx)
|
||||
|
||||
@@ -575,7 +575,7 @@ class Account(object):
|
||||
if not self.is_configured():
|
||||
self.configure()
|
||||
self.wait_configure_finish()
|
||||
lib.dc_context_run(self._dc_context)
|
||||
lib.dc_io_start(self._dc_context)
|
||||
|
||||
def configure(self):
|
||||
assert not self.is_configured()
|
||||
@@ -596,7 +596,7 @@ class Account(object):
|
||||
del self._configtracker
|
||||
|
||||
def is_started(self):
|
||||
return self._event_thread.is_alive() and bool(lib.dc_is_running(self._dc_context))
|
||||
return self._event_thread.is_alive() and bool(lib.dc_io_status(self._dc_context))
|
||||
|
||||
def wait_shutdown(self):
|
||||
""" wait until shutdown of this account has completed. """
|
||||
@@ -607,9 +607,9 @@ class Account(object):
|
||||
self.log("stop_ongoing")
|
||||
self.stop_ongoing()
|
||||
|
||||
if bool(lib.dc_is_running(self._dc_context)):
|
||||
if bool(lib.dc_io_status(self._dc_context)):
|
||||
self.log("context_shutdown (stop core scheduler)")
|
||||
lib.dc_context_shutdown(self._dc_context)
|
||||
lib.dc_io_stop(self._dc_context)
|
||||
else:
|
||||
self.log("stop_scheduler called on non-running context")
|
||||
|
||||
|
||||
37
python/x.py
37
python/x.py
@@ -1,37 +0,0 @@
|
||||
|
||||
import deltachat
|
||||
import os
|
||||
import shutil
|
||||
from deltachat.capi import lib
|
||||
|
||||
try:
|
||||
os.remove("/tmp/db")
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
shutil.rmtree("/tmp/db-blobs")
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
acc = deltachat.Account("/tmp/db", logging=True)
|
||||
acc.set_config("addr", "tmp.hjfcq@five.chat")
|
||||
acc.set_config("mail_pw", "aihWNtLuRJgV")
|
||||
acc.start() # lib.dc_configure + lib.dc_context_run
|
||||
assert acc.is_configured()
|
||||
acc.stop_scheduler()
|
||||
|
||||
run = 0
|
||||
while 1:
|
||||
print("****** starting scheduler")
|
||||
acc.start()
|
||||
import time ; time.sleep(0.5)
|
||||
print("******* stopping scheduler")
|
||||
acc.stop_scheduler()
|
||||
print("******* waiting", run)
|
||||
import time ; time.sleep(1.0)
|
||||
run += 1
|
||||
|
||||
contact = acc.create_contact("holger@deltachat.de")
|
||||
chat = acc.create_chat_by_contact(contact)
|
||||
chat.send_text("hello")
|
||||
Reference in New Issue
Block a user