pub unsafe fn register_task(&mut self,
                         annotation: &Annotation,
                         function: WrapperFunctionCallback,
                         arguments: *const c_void,
                         returns_value: bool) -> Option<Future> {

        debug!("Registering task with {} arguments", annotation.params.len());

        let future_id = if returns_value {
            Some(self.id_gen.next())
        } else {
            None
        };

        // Split the function's arguments into multiple pieces.
        let bytes = arguments as *const u8;
        let mut offset = 0;
        let split_arguments: Vec<_> = annotation.params.iter().map(&mut |a: &SplitTypeParameter| {
            // TODO: The runtime information should be associated with the parameter, not the type.
            // When the task is registered, generic types will not have been resolved.
            let runtime = a.ty.runtime_info();
            let storage = into_vec(bytes.offset(offset), runtime.data_size);
            trace!("Argument buffer: {:?}", storage);
            offset += runtime.data_size as isize;
            storage
        }).collect();
        debug!("register_task consumed {} bytes from the argument", offset);

        // Register the future as an "argument" so we can tie it in with other appearances.
        //
        // future is the valeu that we'll return to the caller.
        let (future, future_storage) = if future_id.is_some() {
            let mut storage: Vec<u8> = vec![0; mem::size_of::<intptr_t>()];     
            let future = self.next_future_pointer();
            byteorder::LittleEndian::write_u64(&mut storage, future.0 as u64);
            (Some(future), Some(storage))
        } else {
            (None, None)
        };

        // Construct the set of ArgumentIds for the task. An argument is assigned a new Id if we
        // don't have that argument registered already. Arguments are considered equal if their
        // stored values are equal (i.e., their bytes are equal) -- note that the stored values may
        // contain pointers, and the pointed-to values are not compared.
        let mut ids = vec![];
        for input_arg in split_arguments.into_iter() {
            let mut set = false;
            for (id, argument) in self.arguments.iter() {
                if *argument == input_arg {
                    ids.push(*id);
                    set = true;
                    break;
                }
            }

            if !set {
                // We didn't find the argument in the arguments registry. Add it in.
                let id = self.id_gen.next();
                self.arguments.insert(id, input_arg);
                ids.push(id);
            }
        }

        if let Some(future_storage) = future_storage {
            // Insert it into the arguments to track where else its used.
            self.arguments.insert(future_id.clone().unwrap(), future_storage);
            self.futures.insert(future_id.unwrap());
        }

        debug!("Registering task with arguments {:?}, returns {:?}", ids, future_id);
        self.tasks.push(Task::new(annotation.clone(), function, ids, future_id));
        future
    }
/// Register a task with the runtime. The annotation should specify an ordered
/// set of arguments for the function being register. `function` is a function pointer
/// that takes a single `*const void` value as an argument.
///
/// `arguments` is a packed C struct with the function arguments.
Register a task with the runtime. The annotation should specify an ordered
set of arguments for the function being register. `function` is a function pointer
that takes a single `*const void` value as an argument.

`arguments` is a packed C struct with the function arguments.
Register a task with the runtime . The annotation should specify an ordered set of arguments for the function being register . ` function ` is a function pointer that takes a single ` * const void ` value as an argument . ` arguments ` is a packed C struct with the function arguments .
pub unsafe fn register_task(&mut self,
                         annotation: &Annotation,
                         function: WrapperFunctionCallback,
                         arguments: *const c_void,
                         returns_value: bool) -> Option<Future> {
        debug!("Registering task with {} arguments", annotation.params.len());
        let future_id = if returns_value {
            Some(self.id_gen.next())
        } else {
            None
        };
        // Split the function's arguments into multiple pieces.
        let bytes = arguments as *const u8;
        let mut offset = 0;
        let split_arguments: Vec<_> = annotation.params.iter().map(&mut |a: &SplitTypeParameter| {
            // TODO: The runtime information should be associated with the parameter, not the type.
            // When the task is registered, generic types will not have been resolved.
            let runtime = a.ty.runtime_info();
            let storage = into_vec(bytes.offset(offset), runtime.data_size);
            trace!("Argument buffer: {:?}", storage);
            offset += runtime.data_size as isize;
            storage
        }).collect();
        debug!("register_task consumed {} bytes from the argument", offset);
        // Register the future as an "argument" so we can tie it in with other appearances.
        //
        // future is the valeu that we'll return to the caller.
        let (future, future_storage) = if future_id.is_some() {
            let mut storage: Vec<u8> = vec![0; mem::size_of::<intptr_t>()];     
            let future = self.next_future_pointer();
            byteorder::LittleEndian::write_u64(&mut storage, future.0 as u64);
            (Some(future), Some(storage))
        } else {
            (None, None)
        };
        // Construct the set of ArgumentIds for the task. An argument is assigned a new Id if we
        // don't have that argument registered already. Arguments are considered equal if their
        // stored values are equal (i.e., their bytes are equal) -- note that the stored values may
        // contain pointers, and the pointed-to values are not compared.
        let mut ids = vec![];
        for input_arg in split_arguments.into_iter() {
            let mut set = false;
            for (id, argument) in self.arguments.iter() {
                if *argument == input_arg {
                    ids.push(*id);
                    set = true;
                    break;
                }
            }
            if !set {
                // We didn't find the argument in the arguments registry. Add it in.
                let id = self.id_gen.next();
                self.arguments.insert(id, input_arg);
                ids.push(id);
            }
        }
        if let Some(future_storage) = future_storage {
            // Insert it into the arguments to track where else its used.
            self.arguments.insert(future_id.clone().unwrap(), future_storage);
            self.futures.insert(future_id.unwrap());
        }
        debug!("Registering task with arguments {:?}, returns {:?}", ids, future_id);
        self.tasks.push(Task::new(annotation.clone(), function, ids, future_id));
        future
    }
pub unsafe fn register_task ( & mut self , annotation : & Annotation , function : WrapperFunctionCallback , arguments : * const c_void , returns_value : bool ) -> Option < Future > { debug ! ( " " annotation params len ( ) ) ; let future_id = if returns_value { Some ( self . id_gen . next ( ) ) } else { None } ; // Split the function's arguments into multiple pieces. let bytes = arguments as * const u8 ; let mut offset = 0 ; let split_arguments : Vec < _ > = annotation . params . iter ( ) . map ( & mut | a : & SplitTypeParameter | { // TODO: The runtime information should be associated with the parameter, not the type. // When the task is registered, generic types will not have been resolved. let runtime = a . ty . runtime_info ( ) ; let storage = into_vec ( bytes . offset ( offset ) , runtime . data_size ) ; trace ! ( " " storage ) ; offset += runtime . data_size as isize ; storage } ) . collect ( ) ; debug ! ( " " offset ) ; // Register the future as an "argument" so we can tie it in with other appearances. // // future is the valeu that we'll return to the caller. let ( future , future_storage ) = if future_id . is_some ( ) { let mut storage : Vec < u8 > = vec ! [ 0 mem size_of intptr_t ( ) ] ; let future = self . next_future_pointer ( ) ; byteorder :: LittleEndian :: write_u64 ( & mut storage , future . 0 as u64 ) ; ( Some ( future ) , Some ( storage ) ) } else { ( None , None ) } ; // Construct the set of ArgumentIds for the task. An argument is assigned a new Id if we // don't have that argument registered already. Arguments are considered equal if their // stored values are equal (i.e., their bytes are equal) -- note that the stored values may // contain pointers, and the pointed-to values are not compared. let mut ids = vec ! [ ] ; for input_arg in split_arguments . into_iter ( ) { let mut set = false ; for ( id , argument ) in self . arguments . iter ( ) { if * argument == input_arg { ids . push ( * id ) ; set = true ; break ; } } if ! set { // We didn't find the argument in the arguments registry. Add it in. let id = self . id_gen . next ( ) ; self . arguments . insert ( id , input_arg ) ; ids . push ( id ) ; } } if let Some ( future_storage ) = future_storage { // Insert it into the arguments to track where else its used. self . arguments . insert ( future_id . clone ( ) . unwrap ( ) , future_storage ) ; self . futures . insert ( future_id . unwrap ( ) ) ; } debug ! ( " " ids future_id ) ; self . tasks . push ( Task :: new ( annotation . clone ( ) , function , ids , future_id ) ) ; future }
Register a task with the runtime.
Register a task with the runtime .
&mut self
annotation
&Annotation
function
WrapperFunctionCallback
arguments
*const c_void
returns_value
bool