Initial library commit.

This commit is contained in:
Jason Travis Smith 2016-03-18 16:17:01 -04:00
commit b83c3970a6
8 changed files with 168 additions and 0 deletions

17
.gitignore vendored Normal file
View File

@ -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

12
Cargo.lock generated Normal file
View File

@ -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"

13
Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "apprentice"
version = "0.1.0"
authors = ["Jason Travis Smith <Jason@CyberMagesLLC.com>"]
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"

12
examples/sample_tasks.rs Normal file
View File

@ -0,0 +1,12 @@
extern crate apprentice;
use apprentice::*;
pub fn main()
{
println!("Hello world");
}

14
src/lib.rs Normal file
View File

@ -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;

60
src/scheduler.rs Normal file
View File

@ -0,0 +1,60 @@
use ::thread::Thread;
///
pub struct Scheduler
{
///
has_unlimited_threads: bool,
///
maximum_thread_amount: u64,
///
thread_list: Vec<Thread>
}
impl Scheduler
{
///
pub fn new(num_threads: Option<u64>) -> 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()
{
}
}

20
src/task.rs Normal file
View File

@ -0,0 +1,20 @@
///
pub struct Task
{
///
name: String
}
impl Task
{
///
pub fn new(task_name: &str) -> Task
{
Task
{
name: String::from(task_name)
}
}
}

20
src/thread.rs Normal file
View File

@ -0,0 +1,20 @@
///
pub struct Thread
{
///
empty: i8
}
impl Thread
{
///
pub fn new() -> Thread
{
Thread
{
empty: 0
}
}
}