Esempio n. 1
0
    context( context_fn sf, stack_allocator& alloc, fc::thread* t )
    : caller_context(0),
      stack_alloc(&alloc),
      next_blocked(0), 
      next_blocked_mutex(0), 
      next(0), 
      ctx_thread(t),
      canceled(false),
#ifndef NDEBUG
      cancellation_reason(nullptr),
#endif
      complete(false),
      cur_task(0),
      context_posted_num(0)
    {
#if BOOST_VERSION >= 105600
     size_t stack_size = FC_CONTEXT_STACK_SIZE;
     alloc.allocate(stack_ctx, stack_size);
     my_context = bc::make_fcontext( stack_ctx.sp, stack_ctx.size, sf); 
#elif BOOST_VERSION >= 105400
     size_t stack_size = FC_CONTEXT_STACK_SIZE;
     alloc.allocate(stack_ctx, stack_size);
     my_context = bc::make_fcontext( stack_ctx.sp, stack_ctx.size, sf);
#elif BOOST_VERSION >= 105300
     size_t stack_size = FC_CONTEXT_STACK_SIZE;
     void*  stackptr = alloc.allocate(stack_size);
     my_context = bc::make_fcontext( stackptr, stack_size, sf);
#else
     size_t stack_size = FC_CONTEXT_STACK_SIZE;
     my_context.fc_stack.base = alloc.allocate( stack_size );
     my_context.fc_stack.limit = static_cast<char*>( my_context.fc_stack.base) - stack_size;
     make_fcontext( &my_context, sf );
#endif
    }
Esempio n. 2
0
	// Currently unsafe!
	//
	// gcFiber->entry will not be gc_marked until fiber is running...
	//
	int createFiber( Entry entry ){
	
		Fiber *fiber=allocFiber();
		if( !fiber ) return 0;
		
		fiber->gcFiber->entry=entry;
		fiber->fcontext=make_fcontext( fiber->stack+STACK_SIZE,STACK_SIZE,fiberEntry );
		
		return fiber->id;
	}
Esempio n. 3
0
 context( void (*sf)(intptr_t), bc::stack_allocator& alloc, fc::thread* t )
 : caller_context(0),
   stack_alloc(&alloc),
   next_blocked(0), 
   next_blocked_mutex(0), 
   next(0), 
   ctx_thread(t),
   canceled(false),
   complete(false),
   cur_task(0)
 {
   my_context.fc_stack.base = alloc.allocate( bc::default_stacksize() );
   my_context.fc_stack.limit = 
     static_cast<char*>( my_context.fc_stack.base) - bc::default_stacksize();
   make_fcontext( &my_context, sf );
 }
Esempio n. 4
0
	// Safe!
	//
	int startFiber( Entry entry ){

		Fiber *fiber=allocFiber();
		if( !fiber ) return 0;

		int id=fiber->id;
		
		fiber->gcFiber->entry=entry;
		fiber->fcontext=make_fcontext( fiber->stack+STACK_SIZE,STACK_SIZE,fiberEntry );
		
		Fiber *curr=currFiber;

		fiber->fcontext=jump_fcontext( fiber->fcontext,fiber ).fcontext;

		setCurrFiber( curr );
		
		return id;
	}