fn on_op()

in netbench/src/client/thread.rs [62:121]


    fn on_op<T: Trace, Ch: Checkpoints>(
        &mut self,
        client: &mut C,
        addresses: &AddressMap,
        op: &'a op::Client,
        trace: &mut T,
        checkpoints: &mut Ch,
        now: Timestamp,
        cx: &mut Context,
    ) {
        trace.exec_client(now, op);
        use op::Client::*;
        match op {
            Sleep { timeout } => {
                self.timer.sleep(now, *timeout);
                self.op = Some(Op::Sleep);
            }
            Connect {
                server_id,
                router_id,
                server_connection_id,
                client_connection_id,
            } => {
                let addr = if let Some(router_id) = router_id {
                    addresses.router(*router_id, *server_id)
                } else {
                    addresses.server(*server_id)
                };
                let hostname = addresses.hostname(*server_connection_id);
                let ops = &self.scenario.connections[*client_connection_id as usize];
                let connect = client.connect(addr, hostname, *server_connection_id, ops);
                self.op = Some(Op::Connect {
                    connect,
                    id: *client_connection_id,
                    start: now,
                });
            }
            Park { checkpoint } => {
                trace.park(now, *checkpoint);
                self.op = Some(Op::Wait {
                    checkpoint: *checkpoint,
                });
            }
            Unpark { checkpoint } => {
                checkpoints.unpark(*checkpoint, cx);
            }
            Trace { trace_id } => {
                trace.trace(now, *trace_id);
            }
            Scope { threads } => {
                if !threads.is_empty() {
                    let threads = threads
                        .iter()
                        .map(|thread| Thread::new(self.scenario, thread))
                        .collect();
                    self.op = Some(Op::Scope { threads });
                }
            }
        }
    }