Skip to content

Commit

Permalink
use thread stack
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Dec 13, 2023
1 parent 1725aaf commit 2ae6085
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/coroutine_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::thread::ThreadId;
use std::time::Duration;

use crate::cancel::Cancel;
use crate::config::{config, DEFAULT_STACK_SIZE};
use crate::config::{config};
use crate::err;
use crate::join::{make_join_handle, Join, JoinHandle};
use crate::local::get_co_local_data;
Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct CoroutineImpl {
impl CoroutineImpl {
pub fn stack_reduce(&mut self) {
if self.reduce.is_none() {
let reduce_data = unsafe { &*self.gen.stack.get() }.stack_reduce(DEFAULT_STACK_SIZE);
let reduce_data = unsafe { &*self.gen.stack.get() }.stack_reduce(crate::config().get_stack_size());
if reduce_data.len() != 0 {
self.reduce = Some(reduce_data);
//alloc a small stack
Expand Down
8 changes: 4 additions & 4 deletions src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::{Arc, Once};
use std::thread;
use std::time::Duration;

use crate::config::{config, DEFAULT_STACK_SIZE};
use crate::config::{config};
use crate::coroutine_impl::{run_coroutine, CoroutineImpl};
use crate::io::{EventLoop, Selector};
use crate::std::sync::AtomicOption;
Expand Down Expand Up @@ -127,7 +127,7 @@ fn init_scheduler() {
println!("init worker {:?}", std::thread::current().id());
let s = unsafe { &*SCHED };
s.worker_ids.insert(std::thread::current().id(), id);
s.stacks.insert(std::thread::current().id(), Stack::new(DEFAULT_STACK_SIZE));
s.stacks.insert(std::thread::current().id(), Stack::new(crate::config().get_stack_size()));
s.event_loop.run(id as usize).unwrap_or_else(|e| {
panic!("event_loop failed running, err={}", e);
});
Expand Down Expand Up @@ -351,9 +351,9 @@ impl Scheduler {
pub fn get_stack(&self,key:std::thread::ThreadId) -> Stack{
match self.stacks.get(&key){
None => {
let v=Stack::new(DEFAULT_STACK_SIZE);
let v=Stack::new(crate::config().get_stack_size());
let r= v.shadow_clone();
self.stacks.insert(key,Stack::new(DEFAULT_STACK_SIZE));
self.stacks.insert(key,Stack::new(crate::config().get_stack_size()));
r
}
Some(v) => {
Expand Down

0 comments on commit 2ae6085

Please sign in to comment.