team-ljyzipelo

공개
48줄1.4 KB
1pub use core_memory as core;
2
3mod transport {
4 include!("../../experiments/rust-ui-memory-app/src/transport.rs");
5}
6
7mod runtime {
8 include!("../../experiments/rust-ui-memory-app/src/runtime.rs");
9
10 // 원본 메서드는 바꾸지 않고 시험 채널과 실제 핸들만 조립함.
11 pub fn assemble(
12 work: impl FnOnce(
13 core::Operation,
14 SyncSender<ProgressEvent>,
15 SyncSender<Completion>,
16 ) -> Option<Completion>
17 + Send
18 + 'static,
19 ) -> Task {
20 let (op, cancellation) = core::Operation::start().unwrap();
21 let id = op.id();
22 let (sender, events) = mpsc::sync_channel(DEFAULT_CAPACITY);
23 let (done, completion) = mpsc::sync_channel(1);
24 let handle = thread::spawn(move || work(op, sender, done));
25 Task {
26 id,
27 cancellation,
28 events: Some(events),
29 completion: Some(completion),
30 handle: Some(handle),
31 }
32 }
33}
34
35mod controller {
36 include!("../../experiments/rust-ui-memory-app/src/controller.rs");
37
38 // 비공개 Receiver를 같은 실제 작업 ID로 초기화하는 시험 경계임.
39 pub fn attach(task: Task) -> Controller {
40 Controller {
41 receiver: Some(core::Receiver::new(task.id)),
42 task: Some(task),
43 generation: 1,
44 status: Status::Running,
45 ..Controller::default()
46 }
47 }
48}