pub struct ActorManager<A, E, R, P>where
    A: Agent<E, R> + SyncModel,
    E: Env,
    P: StepProcessorBase<E>,
    R: ReplayBufferBase<PushedItem = P::Output>,{ /* private fields */ }
Expand description

Manages Actors.

This struct handles the following requests:

  • From the LearnerManager for updating the latest model info, stored in this struct.
  • From the Actors for getting the latest model info.
  • From the Actors for pushing sample batch to the LearnerManager.

Implementations§

source§

impl<A, E, R, P> ActorManager<A, E, R, P>where A: Agent<E, R> + SyncModel, E: Env, P: StepProcessorBase<E>, R: ReplayBufferBase<PushedItem = P::Output> + Send + 'static, A::Config: Send + 'static, E::Config: Send + 'static, P::Config: Send + 'static, R::PushedItem: Send + 'static, A::ModelInfo: Send + 'static,

source

pub fn build( config: &ActorManagerConfig, agent_configs: &Vec<A::Config>, env_config: &E::Config, step_proc_config: &P::Config, pushed_item_message_sender: Sender<PushedItemMessage<R::PushedItem>>, model_info_receiver: Receiver<(usize, A::ModelInfo)>, stop: Arc<Mutex<bool>> ) -> Self

Builds a ActorManager.

source

pub fn run(&mut self, guard_init_env: Arc<Mutex<bool>>)

Runs threads for Actors and a thread for sending samples into the replay buffer.

A thread will wait for the initial SyncModel::ModelInfo from AsyncTrainer, which blocks execution of Actor threads.

source

pub fn join(self) -> Vec<ActorStat>

Waits until all actors finish.

source

pub fn stop(&self)

Stops actor threads.

source

pub fn stop_and_join(self) -> Vec<ActorStat>

Stops and joins actors.

Auto Trait Implementations§

§

impl<A, E, R, P> !RefUnwindSafe for ActorManager<A, E, R, P>

§

impl<A, E, R, P> Send for ActorManager<A, E, R, P>where R: Send, <A as Policy<E>>::Config: Send, <E as Env>::Config: Send, <P as StepProcessorBase<E>>::Config: Send, <A as SyncModel>::ModelInfo: Send, <P as StepProcessorBase<E>>::Output: Send,

§

impl<A, E, R, P> Sync for ActorManager<A, E, R, P>where R: Sync, <A as Policy<E>>::Config: Sync, <E as Env>::Config: Sync, <P as StepProcessorBase<E>>::Config: Sync, <A as SyncModel>::ModelInfo: Send, <P as StepProcessorBase<E>>::Output: Send,

§

impl<A, E, R, P> Unpin for ActorManager<A, E, R, P>where R: Unpin, <A as Policy<E>>::Config: Unpin, <E as Env>::Config: Unpin, <P as StepProcessorBase<E>>::Config: Unpin, <A as SyncModel>::ModelInfo: Unpin, <P as StepProcessorBase<E>>::Output: Unpin,

§

impl<A, E, R, P> !UnwindSafe for ActorManager<A, E, R, P>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V