[][src]Struct weld::WeldContext

pub struct WeldContext { /* fields omitted */ }

A context for a Weld program.

Contexts are internally reference counted, so cloning a context will produce a reference to the same internal object. The reference-counted internal object is protected via a RefCell to prevent double-mutable-borrows: this is necessary because contexts may not be passed into multiple WeldModule::run calls in parallel, even if they are cloned (since cloned contexts point to the same underlying object).

Contexts are not thread-safe, and thus do not implement Send+Sync.

Methods

impl WeldContext[src]

pub fn new(conf: &WeldConf) -> WeldResult<WeldContext>[src]

Returns a new WeldContext with the given configuration.

Errors

Returns an error if the configuration is malformed.

Examples

use weld::{WeldConf, WeldContext};

// Create a new default configuration.
let conf = &mut WeldConf::new();

// Set 1KB memory limit, 2 worker threads.
conf.set("weld.memory.limit", "1024");
conf.set("weld.threads", "2");

// Create a context.
let context = WeldContext::new(conf).unwrap();

pub fn memory_usage(&self) -> i64[src]

Returns the memory used by this context.

Examples

use weld::{WeldConf, WeldContext};

let context = WeldContext::new(&WeldConf::new()).unwrap();
assert_eq!(context.memory_usage(), 0);

pub fn memory_limit(&self) -> i64[src]

Returns the memory limit of this context.

Examples

use weld::{WeldConf, WeldContext};

let conf = &mut WeldConf::new();

// Set 1KB memory limit, 2 worker threads.
conf.set("weld.memory.limit", "1024");

let context = WeldContext::new(conf).unwrap();
assert_eq!(context.memory_limit(), 1024);

Trait Implementations

impl Clone for WeldContext[src]

impl Debug for WeldContext[src]

impl PartialEq<WeldContext> for WeldContext[src]

impl StructuralPartialEq for WeldContext[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.