commit b83c3970a6e93b69b79f1355180707def370ded5 Author: Jason Travis Smith Date: Fri Mar 18 16:17:01 2016 -0400 Initial library commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..48f68fb --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Ignore swap files from text editors. +*.swp + +# Ignore compiled files. +*.o +*.so +*.rlib +*.dll +*.exe + +# Ignore files/directories generated by Cargo. +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, +# leave it for libraries. +# More information here: http://doc.crates.io/guide.html#cargotoml-vs-cargolock +#Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..3361a4c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,12 @@ +[root] +name = "apprentice" +version = "0.1.0" +dependencies = [ + "scribe 0.1.0 (git+https://gitlab.com/CyberMages/scribe.git)", +] + +[[package]] +name = "scribe" +version = "0.1.0" +source = "git+https://gitlab.com/CyberMages/scribe.git#d6a6f5107c8d03b13e081c9378486781e31daa4e" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a3cc451 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "apprentice" +version = "0.1.0" +authors = ["Jason Travis Smith "] +description = "A Rust task scheduler." +license = "" +repository = "https://gitlab.com/CyberMages/apprentice.git" +documentation = "" +keywords = ["scheduler", "task", "thread"] + + +[dependencies.scribe] +git = "https://gitlab.com/CyberMages/scribe.git" diff --git a/examples/sample_tasks.rs b/examples/sample_tasks.rs new file mode 100644 index 0000000..aff243a --- /dev/null +++ b/examples/sample_tasks.rs @@ -0,0 +1,12 @@ +extern crate apprentice; + + + +use apprentice::*; + + + +pub fn main() +{ + println!("Hello world"); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..00d028c --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,14 @@ +#[macro_use] +extern crate scribe; + + + +mod scheduler; +mod task; +mod thread; + + + +pub use self::scheduler::Scheduler; +pub use self::task::Task; +pub use self::thread::Thread; diff --git a/src/scheduler.rs b/src/scheduler.rs new file mode 100644 index 0000000..ae15a01 --- /dev/null +++ b/src/scheduler.rs @@ -0,0 +1,60 @@ +use ::thread::Thread; + + + +/// +pub struct Scheduler +{ + /// + has_unlimited_threads: bool, + + /// + maximum_thread_amount: u64, + + /// + thread_list: Vec +} + + + +impl Scheduler +{ + /// + pub fn new(num_threads: Option) -> Scheduler + { + let thread_count: u64; + let unlimited_threads: bool; + + // Check to see if the scheduler will + // be using unlimited threads. + match num_threads + { + Some(count) => + { + // Set the maximum number of threads to be the desired + // amount. + thread_count = count; + unlimited_threads = false; + } + + None => + { + // Set that there can be an unlimited amount of threads. + thread_count = 0; + unlimited_threads = true; + } + } + + // Create the new Scheduler. + Scheduler + { + has_unlimited_threads: unlimited_threads, + maximum_thread_amount: thread_count, + thread_list: Vec::new() + } + } + + fn create_thread() + { + } +} diff --git a/src/task.rs b/src/task.rs new file mode 100644 index 0000000..0b3f403 --- /dev/null +++ b/src/task.rs @@ -0,0 +1,20 @@ +/// +pub struct Task +{ + /// + name: String +} + + + +impl Task +{ + /// + pub fn new(task_name: &str) -> Task + { + Task + { + name: String::from(task_name) + } + } +} diff --git a/src/thread.rs b/src/thread.rs new file mode 100644 index 0000000..02ff231 --- /dev/null +++ b/src/thread.rs @@ -0,0 +1,20 @@ +/// +pub struct Thread +{ + /// + empty: i8 +} + + + +impl Thread +{ + /// + pub fn new() -> Thread + { + Thread + { + empty: 0 + } + } +}