This project is an extension of Project 4: Prosumer/Consumer with different implementations and additional functionality. The goal of this project is to implement a simple banking application with Rust. Particularly, there is multiple accounts in the bank and each account has a balance where we can deposit, withdraw, or transfer money between accounts.
- The project is implemented with Rust which has several advantages over C++. For example, Rust provides the memory safety through ownership and borrowing rule, eliminating many common programmings errorsm such as null pointer dereferences. Rust also has a lightweight concurrency model (referred as "fearless concurrency")that makes it easy to write concurrent programs without introducing data races or deadlocks, providng a safe and write .
- The program will initialize a bank with 10 accounts. Then, it loads a text file containing the information of the ledger and creates "num_workers" (input from terminal) threads to process the transactions in the ledger list concurrently. Finally, the program will print the balance of all the accounts in the bank.
- Create multiple concurrent tasks using Rust's built-in threading capabilities.
- Apply Rust's ownership and borrowing system to minimize the scope and duration of critical sections, reducing the likelihood of data races.
- Employ Rust's synchronization primitives, such as Mutex and RwLock, to prevent deadlocks and ensure thread-safe execution.
-
Make sure you have Rust and Cargo installed. If not, follow the official Rust installation guide: Rust Installation Guide.
-
Clone the repository:
git clone https://github.com/ThomasN12/bank-system-rust
-
Navigate the project directory:
cd bank-system
-
Build the project using Cargo:
cargo build
-
Run the project with the following command:
cargo run -- <num_workers> <ledger_filename>
- Link to video
- Link to video-2 (In case the first one not working)