This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Our "consumer", who is passed a "chan", which is the "consumer chan" | |
| // the main thread shared with it to send results on back to the main thread. | |
| // It also returns a "consumer chan", which is the sender that is shared with each worker. | |
| fn start_consumer(chan: Sender<ConsumerControlMsg>, | |
| number_of_workflows: usize, | |
| number_of_steps: usize) | |
| -> Sender<ConsumerMsg> { | |
| // The consumer chan, sender will be shared with each worker. | |
| let (consumer_chan, consumer_port) = channel(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loop { | |
| // "msg" is the result of the "select" above... | |
| let result = match msg { | |
| MainMsg::FromProducer(ProducerMsg::Incoming(workflow)) => { | |
| // Distribute the work among workers... | |
| // then continue... | |
| continue; | |
| }, | |
| MainMsg::FromConsumer(msg) => msg | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct WorkflowExecutor { | |
| executions: VecDeque<(Workflow, WorkflowExecution)>, | |
| port: Receiver<ExecutorMsg>, | |
| chan: Sender<ConsumerMsg> | |
| } | |
| impl WorkflowExecutor { | |
| fn handle_a_msg(&mut self) -> bool { | |
| match self.port.try_recv() { | |
| Ok(ExecutorMsg::Execute(workflow)) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Our "consumer", is shared with a "chan", which is the "consumer chan", | |
| // the main thread shared with it, to send results on back to the main thread. | |
| // It also returns a "consumer chan", which is the sender that is shared with each worker. | |
| fn start_consumer(chan: Sender<ConsumerControlMsg>, | |
| number_of_workflows: usize, | |
| number_of_steps: usize) | |
| -> Sender<ConsumerMsg> { | |
| // The consumer chan, sender will be shared with each worker. | |
| let (consumer_chan, consumer_port) = channel(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ExecutorControlChan { | |
| id: ExecutorId, | |
| chan: Sender<(ExecutorId, ExecutorControlMsg)> | |
| } | |
| impl ExecutorControlChan { | |
| fn send(&self, msg: ExecutorControlMsg) { | |
| let _ = self.chan.send((self.id, msg)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn start_executor(chan: Sender<ConsumerMsg>) -> Sender<ExecutorMsg> { | |
| let (executor_chan, executor_port) = channel(); | |
| let _ = thread::Builder::new().spawn(move || { | |
| let mut executor = WorkflowExecutor { | |
| executions: Default::default(), | |
| port: executor_port, | |
| chan: chan, | |
| }; | |
| while executor.run() { | |
| // Running... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum PipelineMsg { | |
| Generated(u8), | |
| Squared(u8), | |
| Merged(u8), | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn square(merge_chan: Sender<PipelineMsg>) -> Sender<PipelineMsg> { | |
| let (chan, port) = channel(); | |
| let _ = thread::Builder::new().spawn(move || { | |
| for msg in port { | |
| // Check that the msg is of the expected variant. | |
| let num = match msg { | |
| PipelineMsg::Generated(num) => num, | |
| _ => panic!("unexpected message receiving at square stage"), | |
| }; | |
| // Send a message of the variant corresponding to the next stage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// The key used to differentiate requests in the cache. | |
| #[derive(Clone, Eq, Hash, MallocSizeOf, PartialEq )] | |
| pub struct CacheKey { | |
| url: ServoUrl | |
| } | |
| /// A complete cached resource. | |
| #[derive(Clone)] | |
| struct CachedResource { | |
| request_headers: Arc<Mutex<Headers>>, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub struct HttpState { | |
| pub hsts_list: RwLock<HstsList>, | |
| pub cookie_jar: RwLock<CookieStorage>, | |
| pub http_cache: RwLock<HttpCache>, | |
| pub auth_cache: RwLock<AuthCache>, | |
| pub history_states: RwLock<HashMap<HistoryStateId, Vec<u8>>>, | |
| pub ssl_client: OpensslClient, | |
| pub connector: Pool<Connector>, | |
| } |