mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
format apps/chat-test
This commit is contained in:
parent
145e156fe6
commit
b479d56c10
2 changed files with 11 additions and 23 deletions
|
|
@ -11,12 +11,7 @@ use xous_ipc::Buffer;
|
|||
|
||||
fn main() -> ! {
|
||||
let stack_size = 1024 * 1024;
|
||||
std::thread::Builder::new()
|
||||
.stack_size(stack_size)
|
||||
.spawn(wrapped_main)
|
||||
.unwrap()
|
||||
.join()
|
||||
.unwrap()
|
||||
std::thread::Builder::new().stack_size(stack_size).spawn(wrapped_main).unwrap().join().unwrap()
|
||||
}
|
||||
|
||||
fn wrapped_main() -> ! {
|
||||
|
|
@ -26,11 +21,8 @@ fn wrapped_main() -> ! {
|
|||
|
||||
const HEAP_LARGER_LIMIT: usize = 2048 * 1024;
|
||||
let new_limit = HEAP_LARGER_LIMIT;
|
||||
let result = xous::rsyscall(xous::SysCall::AdjustProcessLimit(
|
||||
xous::Limits::HeapMaximum as usize,
|
||||
0,
|
||||
new_limit,
|
||||
));
|
||||
let result =
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(xous::Limits::HeapMaximum as usize, 0, new_limit));
|
||||
|
||||
if let Ok(xous::Result::Scalar2(1, current_limit)) = result {
|
||||
xous::rsyscall(xous::SysCall::AdjustProcessLimit(
|
||||
|
|
@ -45,9 +37,7 @@ fn wrapped_main() -> ! {
|
|||
}
|
||||
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let sid = xns
|
||||
.register_name(SERVER_NAME_MTXCHAT, None)
|
||||
.expect("can't register server");
|
||||
let sid = xns.register_name(SERVER_NAME_MTXCHAT, None).expect("can't register server");
|
||||
log::trace!("registered with NS -- {:?}", sid);
|
||||
|
||||
let chat = Chat::new(
|
||||
|
|
@ -85,13 +75,11 @@ fn wrapped_main() -> ! {
|
|||
});
|
||||
}
|
||||
Some(ChatTestOp::Post) => {
|
||||
let buffer =
|
||||
unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let s = buffer
|
||||
.to_original::<xous_ipc::String<{ POST_TEXT_MAX }>, _>()
|
||||
.unwrap();
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let s = buffer.to_original::<xous_ipc::String<{ POST_TEXT_MAX }>, _>().unwrap();
|
||||
if s.len() > 0 {
|
||||
// capture input instead of calling here, so message can drop and calling server is released
|
||||
// capture input instead of calling here, so message can drop and calling server is
|
||||
// released
|
||||
log::info!("got Post {:?}", s.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,9 +13,9 @@ pub fn test_ui(chat: &Chat) {
|
|||
chat.post_add("alice", 1_700_000_000, "hello world!", None).ok();
|
||||
chat.post_add("bob", 1_700_000_002, "hi alice!", None).ok();
|
||||
for i in 0..5 {
|
||||
chat.post_add("alice", 1_700_000_005 + i*4, &format!("alice sez {}", i), None).ok();
|
||||
chat.post_add("bob", 1_700_000_006 + i*4, &format!("bob sez {}", i), None).ok();
|
||||
chat.post_add("trent", 1_700_000_007 + i*4, &format!("trent sez {}", i), None).ok();
|
||||
chat.post_add("alice", 1_700_000_005 + i * 4, &format!("alice sez {}", i), None).ok();
|
||||
chat.post_add("bob", 1_700_000_006 + i * 4, &format!("bob sez {}", i), None).ok();
|
||||
chat.post_add("trent", 1_700_000_007 + i * 4, &format!("trent sez {}", i), None).ok();
|
||||
}
|
||||
chat.post_add("alice", 1_700_001_000, "eom", None).ok();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue