Struct weld::WeldContext[][src]

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]

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 ref mut conf = 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();

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

Returns the memory limit of this context.

Examples

use weld::{WeldConf, WeldContext};

let ref mut conf = 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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for WeldContext
[src]

Formats the value using the given formatter. Read more

impl PartialEq for WeldContext
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

impl !Send for WeldContext

impl !Sync for WeldContext