Anki is a smart spaced repetition flashcard program
Find a file
Aleksa Sarai 312393e825
rs: remove most &mut references in BackendService
The previous implementation had some slightly questionable memory safety
properties (older versions of PyO3 didn't uphold the Rust aliasing rules
and would thus create multiple &mut references to #[pyclass] objects).
This explains why Backend has internal Mutex<T>s even though all of its
methods took &mut self.

The solution is to simply make all methods take &self, which luckily
doesn't pose too make issues -- most of the code inside Backend already
has sufficient locking. The only two things which needed to be
explicitly handled where:

1. "self.runtime" which was fairly easy to handle. All usages of
   the Runtime only require an immutable reference to create a new
   Handle, so we could switch to OnceCell which provides
   lazy-initialisation semantics without needing a more heavy-handed
   Mutex<tokio::runtime::Handle>.

2. "self.sync_abort" was simply wrapped in a Mutex<>, though some of the
   odd semantics of sync_abort (not being able to handle multiple
   processes synchronising at the same time) become pretty obvious with
   this change (for now we just log a warning in that case). In
   addition, switch to an RAII-style guard to make sure we don't forget
   to clear the abort_handle.

As a result, we now no longer break Rust's aliasing rules and we can
build with newer versions of PyO3 which have runtime checks for these
things (and build on stable Rust).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:37:59 +10:00
.github disable pyenv cache on Linux 2020-09-01 09:11:07 +10:00
meta bump version 2020-08-31 11:07:54 +10:00
proto set_deck() 2020-09-03 17:42:46 +10:00
pylib rebuild_filtered_deck() and new_filtered() 2020-09-03 18:02:47 +10:00
qt another showDupes fix from ANH 2020-09-04 10:13:30 +10:00
rslib rs: remove most &mut references in BackendService 2020-09-05 19:37:59 +10:00
rspy rs: remove most &mut references in BackendService 2020-09-05 19:37:59 +10:00
scripts vendor rename script 2020-04-14 19:49:07 +10:00
ts fix custom study link being shown in filtered deck 2020-09-04 08:31:33 +10:00
.gitattributes ftl git attributes 2020-03-20 20:33:12 +10:00
.gitignore save profile stats to file instead of generating report 2020-05-16 12:53:01 +10:00
CONTRIBUTORS add myself to CONTRIBUTORS 2020-08-28 16:48:45 -05:00
LICENSE vendor rename script 2020-04-14 19:49:07 +10:00
Makefile Fix make fix not working on a clean install 2020-08-21 22:15:14 -03:00
pkgkey.asc add public key for release signing 2018-09-18 10:40:45 +10:00
README.contributing Revert "Merge pull request #729 from evandroforks/upload_rslib_artifacts" 2020-08-21 19:56:17 +10:00
README.development mention pypi 2020-08-03 15:31:22 +10:00
README.md drop alpha warning 2020-07-01 15:01:51 +10:00
run remove python version debugging from ./run 2020-04-20 11:21:27 +10:00

This repo contains all the code for the computer version of Anki.

If you'd like to try development builds of Anki but don't feel comfortable building the code, please see https://betas.ankiweb.net/#/

For more information on building, please see README.development.

If you'd like to contribute code, please see README.contributing.