当前位置: 首页>>代码示例>>C++>>正文


C++ LEAVE_CRITICAL_SECTION函数代码示例

本文整理汇总了C++中LEAVE_CRITICAL_SECTION函数的典型用法代码示例。如果您正苦于以下问题:C++ LEAVE_CRITICAL_SECTION函数的具体用法?C++ LEAVE_CRITICAL_SECTION怎么用?C++ LEAVE_CRITICAL_SECTION使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了LEAVE_CRITICAL_SECTION函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ENTER_CRITICAL_SECTION

void CMainFrame::OnCommand(UINT /*wNotifyCode*/, int wID, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	// Commands which do not change the tree are sent to the object directly.
	CTreeItem itemSelected = m_view.GetSelectedItem();

	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectPtr obj;
	const CObjectUIHandler *phandler;
	obj = m_mapObject[m_view.GetItemData(itemSelected)];
	ATLASSERT( obj.get() != NULL );
	phandler = CObjectUIHandler::GetUIHandler( obj );
	phandler->OnCommand( obj, wID );
	
	m_view.UpdateDiskObject( obj );

	OnSelChanged(NULL);

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}
开发者ID:yzx65,项目名称:ndas4windows,代码行数:26,代码来源:nbmainfrm.cpp

示例2: ENTER_CRITICAL_SECTION

/**
 * @brief get message that matches the header in the queue
 *
 * NOTE it matches only daddr, saddr, did, sid, type
 * NOTE it only gets the first that matches the description
 */
Message *mq_get(mq_t *q, Message *m)
{
  HAS_CRITICAL_SECTION;
  Message *ret;

#ifdef SOS_USE_PREEMPTION
  if(q->head == NULL) return NULL;
  ENTER_CRITICAL_SECTION();

  // Search the queue
  ret = mq_real_get(&(q->head), m);
#else
  if(q->msg_cnt == 0) return NULL;
  ENTER_CRITICAL_SECTION();
	
  //! first search high priority queue
  ret = mq_real_get(&(q->hq_head), &(q->hq_tail), m);

  if(ret) {
	q->msg_cnt--;
	LEAVE_CRITICAL_SECTION();
	return ret;
  }
  //! search low priority queue
  ret = mq_real_get(&(q->lq_head), &(q->lq_tail), m);
  if(ret) {
	q->msg_cnt--;
  }
#endif
  LEAVE_CRITICAL_SECTION();
  return ret;
}
开发者ID:nesl,项目名称:sos-2x,代码行数:38,代码来源:message_queue.c

示例3: sp_create

sp_pid_t sp_create( task_t task, uint8_t priority )
{
  sp_pid_t i;
  HAS_CRITICAL_SECTION;
  
  ENTER_CRITICAL_SECTION();
  // Search for empty slot
  for( i = 0; i < SPK_MAX_TASKS; i++ ) {
    // Found an empty slot
    if( spk_tasks[i].task == NULL ) {
      spk_tasks[i].lc       = 0;
      // The pid field is not being used
      spk_tasks[i].status   = TASK_WAITING;
      spk_tasks[i].priority = priority;
      spk_tasks[i].errno    = 0;
      spk_tasks[i].task     = task;
      spk_tasks[i].wait_obj = NULL;
      spk_tasks[i].next     = NULL;
      LEAVE_CRITICAL_SECTION();
      sp_signal( i );
      return i;
    }
  }
  // All slots taken
  LEAVE_CRITICAL_SECTION();
  SP_EXCEPTION();
  return 0;
}
开发者ID:nesl,项目名称:splt,代码行数:28,代码来源:sp_task.c

示例4: sp_signal_error

void sp_signal_error( sp_pid_t pid, uint8_t err )
{
	HAS_CRITICAL_SECTION;
	
	ENTER_CRITICAL_SECTION();
	if( spk_tasks[pid].status != TASK_WAITING ) {
		LEAVE_CRITICAL_SECTION();
		return;
	}
	spk_tasks[pid].errno = err;
	LEAVE_CRITICAL_SECTION();
	sp_signal( pid );
}
开发者ID:nesl,项目名称:splt,代码行数:13,代码来源:sp_task.c

示例5: os_semaphore_wait

int8_t os_semaphore_wait(t_os_semaphore *semaphore) {
    ENTER_CRITICAL_SECTION();
    if (semaphore->count > 0) {
        semaphore->count--;
        LEAVE_CRITICAL_SECTION();
        return 0;
    }
    uint8_t pid = os_get_current_pid();
    semaphore->wait_list[pid] = 1;
    pcb[pid].semaphore_blocked = 1;
    LEAVE_CRITICAL_SECTION();
    os_switch_processes();
    return 0;
}
开发者ID:brunsa2,项目名称:Embedded-operating-system,代码行数:14,代码来源:os-semaphore.c

示例6: radio_msg_alloc

/*************************************************************************
 * will be called by post_net, etc functions to send message             *
 *************************************************************************/
void radio_msg_alloc(Message *msg)
{
	HAS_CRITICAL_SECTION;
	uint16_t sleeptime = 0;
	uint8_t resend_pack = 1;

	ENTER_CRITICAL_SECTION();

	if( Radio_Check_CCA() ) {
		incSeq();
		if(radio_msg_send(msg))
		{
			resend_pack = 0;
			msg_send_senddone(msg, 1, RADIO_PID);
		}
	}
	
	if(resend_pack)
	{
		if( getMsgNumOfQueue() < MAX_MSGS_IN_QUEUE )		//queue is full?
		{
			mq_enqueue(&vmac_pq, msg);
			ENTER_CRITICAL_SECTION(); // most probably mq_enqueue calls LEAVE_CRITICAL_SECTION somewhere!
		}
		else
		{
			msg_send_senddone(msg, 0, RADIO_PID);		//release the memory for the msg
			ENTER_CRITICAL_SECTION(); // most probably msg_send_senddone calls LEAVE_CRITICAL_SECTION somewhere!
		}
		sleeptime = MacBackoff_congestionBackoff(retry_count);
		ker_timer_restart(RADIO_PID, WAKEUP_TIMER_TID, sleeptime);	// setup backoff timer
	}

	LEAVE_CRITICAL_SECTION();
}
开发者ID:nesl,项目名称:sos-2x,代码行数:38,代码来源:vmac.c

示例7: key_get_shift_status

//	Set global shift_status with modifier results (shift, ctrl, alt).
uint key_get_shift_status()
{
	unsigned int shift_status = 0;

	if ( !key_inited ) return 0;

	ENTER_CRITICAL_SECTION( key_lock );		

	if ( keyd_pressed[KEY_LSHIFT] || keyd_pressed[KEY_RSHIFT] )
		shift_status |= KEY_SHIFTED;

	if ( keyd_pressed[KEY_LALT] || keyd_pressed[KEY_RALT] )
		shift_status |= KEY_ALTED;

	if ( keyd_pressed[KEY_LCTRL] || keyd_pressed[KEY_RCTRL] )
		shift_status |= KEY_CTRLED;

#ifndef NDEBUG
	if (keyd_pressed[KEY_DEBUG_KEY])
		shift_status |= KEY_DEBUGGED;
#else
	if (keyd_pressed[KEY_DEBUG_KEY]) {
		mprintf(("Cheats_enabled = %i, Key_normal_game = %i\n", Cheats_enabled, Key_normal_game));
		if ((Cheats_enabled) && Key_normal_game) {
			mprintf(("Debug key\n"));
			shift_status |= KEY_DEBUGGED1;
		}
	}
#endif
	LEAVE_CRITICAL_SECTION( key_lock );		

	return shift_status;
}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:34,代码来源:key.cpp

示例8: timer_hardware_init

/** 
 * @brief timer hardware routine
 */
void timer_hardware_init(uint8_t interval, uint8_t scale){
	HAS_CRITICAL_SECTION;
	ENTER_CRITICAL_SECTION();

	scale &= 0x7;
	scale |= (1<<WGM1); // reset on match
	

	TIMSK &= ((unsigned char)~(1 << (TOIE0)));
	TIMSK &= ((unsigned char)~(1 << (OCIE0)));
	//!< Disable TC0 interrupt

	/** 
	 *  set Timer/Counter0 to be asynchronous 
	 *  from the CPU clock with a second external 
	 *  clock(32,768kHz)driving it
	 */
	ASSR |= (1 << (AS0)); //!< us external oscillator
	TCCR0 = scale;
	TCNT0 = 0;
	OCR0 = interval;
	//TIMSK |= (1 << (OCIE0)); replaced by the line below
	timer_enable_interrupt();
	LEAVE_CRITICAL_SECTION();

	timer_init();
}   
开发者ID:nesl,项目名称:sos-2x,代码行数:30,代码来源:timer.c

示例9: __attribute__

/**
 * Write a block of data into flash (block size is 64 bytes)
 * Note: this routine has to be in the RAM.
 */
static void __attribute__ ((section(".data"))) flash_write_block( uint32_t addr, uint8_t* buf, uint16_t len )
{
	HAS_CRITICAL_SECTION;
	register uint16_t i;
	register uint16_t* d = (uint16_t*) ((uint16_t)addr);
	register uint16_t* b = (uint16_t*) buf;
	
	ENTER_CRITICAL_SECTION();
	while( FCTL3 & BUSY );
	
	FCTL2 = FWKEY + FSSEL1 + FN2;   // SMCLK / 5
	FCTL3 = FWKEY;                  // Clear LOCK
	FCTL1 = FWKEY + BLKWRT + WRT;   // Enable block write
	
	for( i = 0; i < 32; i++ ) {
		*d = *b;
		d++;
		b++;
		while( (FCTL3 & WAIT) == 0);
	}

	FCTL1 = FWKEY;                  // Clear WRT and BLKWRT
	
	while( FCTL3 & BUSY );          // Test Busy
	
	FCTL3 = FWKEY + LOCK;           // Set LOCK

	LEAVE_CRITICAL_SECTION();
}
开发者ID:nesl,项目名称:sos-2x,代码行数:33,代码来源:flash_api.c

示例10: mouse_init

void mouse_init()
{
	// Initialize queue
	if ( mouse_inited ) return;
	mouse_inited = 1;

	InitializeCriticalSection( &mouse_lock );

	ENTER_CRITICAL_SECTION(&mouse_lock);

	mouse_flags = 0;
	Mouse_x = gr_screen.max_w / 2;
	Mouse_y = gr_screen.max_h / 2;

#ifdef USE_DIRECTINPUT
	if (!di_init())
		Mouse_mode = MOUSE_MODE_WIN;
#else
	Mouse_mode = MOUSE_MODE_WIN;
#endif

	LEAVE_CRITICAL_SECTION(&mouse_lock);	

	atexit( mouse_close );
}
开发者ID:chief1983,项目名称:Imperial-Alliance,代码行数:25,代码来源:MOUSE.CPP

示例11: SafeRealloc

int SafeRealloc(void **Memory_ptr, size_t NewBytes)
{
	void *New;
#ifdef WIN32
	ENTER_CRITICAL_SECTION(AllocCS);
#else
	LOCK_SPIN(AllocSpin);
#endif /* WIN32 */

	New = realloc(*Memory_ptr, NewBytes);

#ifdef WIN32
	LEAVE_CRITICAL_SECTION(AllocCS);
#else
	UNLOCK_SPIN(AllocSpin);
#endif /* WIN32 */

	if(New != NULL)
	{
		*Memory_ptr = New;
		return 0;
	} else {
		return -1;
	}
}
开发者ID:galenzhao,项目名称:dnsforwarder,代码行数:25,代码来源:utils.c

示例12: timer_init

/**
 * Timer initialization
 */
void timer_init(uint8_t interval, uint8_t scale)
{
    HAS_CRITICAL_SECTION;
    ENTER_CRITICAL_SECTION();
                                                                               
    scale &= 0x7;
    scale |= 0x8;
                                                                               
    cbi(TIMSK, TOIE0);
    cbi(TIMSK, OCIE0);
    //!< Disable TC0 interrupt
                                                                               
    /**
     *  set Timer/Counter0 to be asynchronous
     *  from the CPU clock with a second external
     *  clock(32,768kHz)driving it
     */
    sbi(ASSR, AS0);
    outp(scale, TCCR0);    //!< prescale the timer to be clock/128 to make it
                                                                               
    outp(0, TCNT0);
    outp(interval, OCR0);
    sbi(TIMSK, OCIE0);
    LEAVE_CRITICAL_SECTION();
}
开发者ID:minf,项目名称:avrora,代码行数:28,代码来源:measure.c

示例13: mouse_up_count

// mouse_up_count() returns the number of times button n has gone from down to up
// since the last call
//
// parameters:  n - button of mouse (see #define's in mouse.h)
//
int mouse_up_count(int n)
{
	int tmp = 0;
	if ( !mouse_inited ) return 0;

	if ( (n < LOWEST_MOUSE_BUTTON) || (n > HIGHEST_MOUSE_BUTTON)) return 0;

	ENTER_CRITICAL_SECTION( mouse_lock );

	switch (n) {
		case MOUSE_LEFT_BUTTON:
			tmp = mouse_left_up;
			mouse_left_up = 0;
			break;

		case MOUSE_RIGHT_BUTTON:
			tmp = mouse_right_up;
			mouse_right_up = 0;
			break;

		case MOUSE_MIDDLE_BUTTON:
			tmp = mouse_middle_up;
			mouse_middle_up = 0;
			break;

		default:
			Assert(0);	// can't happen
			break;
	} // end switch

	LEAVE_CRITICAL_SECTION( mouse_lock );	

	return tmp;
}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:39,代码来源:mouse.cpp

示例14: ker_spi_send_data

/**
 * Send data over the spi
 */
int8_t ker_spi_send_data(
		uint8_t *msg,
		uint8_t msg_size,
		uint8_t calling_id) {
	HAS_CRITICAL_SECTION;

	if (s.state == SPI_SYS_IDLE) {
		return -EINVAL;
	}	
	if ((s.calling_mod_id != calling_id) || ((s.state != SPI_SYS_WAIT) && (s.state != SPI_SYS_DMA_WAIT))) {
		return -EBUSY;
	}

	// ensure calling app gave us a message
	if (NULL != msg) {
		s.usrBuf = s.bufPtr = msg;
	} else {
		return -EINVAL;
	}
	
	// need to assert CS pin
	if (s.flags & SPI_SYS_CS_HIGH_FLAG) {
		spi_cs_high(s.addr);
	} else {
		spi_cs_low(s.addr);
	}

	ENTER_CRITICAL_SECTION();
	s.len = msg_size;
	s.state = SPI_SYS_TX;
	LEAVE_CRITICAL_SECTION();
	UART_DBG(a, 0x22, s.calling_mod_id, 0x01, 0x02, SPI_PID);
	
  return spi_masterTxData(s.bufPtr, s.len, s.flags);
}
开发者ID:nesl,项目名称:sos-2x,代码行数:38,代码来源:spi_system.c

示例15: key_flush

//	Flush the keyboard buffer.
//	Clear the keyboard array (keyd_pressed).
void key_flush()
{
	int i;
	uint CurTime;

	if ( !key_inited ) return;

	ENTER_CRITICAL_SECTION( key_lock );	

	key_data.keyhead = key_data.keytail = 0;

	//Clear the keyboard buffer
	for (i=0; i<KEY_BUFFER_SIZE; i++ )	{
		key_data.keybuffer[i] = 0;
		key_data.time_pressed[i] = 0;
	}
	
	//Clear the keyboard array

	CurTime = timer_get_milliseconds();


	for (i=0; i<NUM_KEYS; i++ )	{
		keyd_pressed[i] = 0;
		key_data.TimeKeyDownChecked[i] = CurTime;
		key_data.TimeKeyWentDown[i] = CurTime;
		key_data.TimeKeyHeldDown[i] = 0;
		key_data.NumDowns[i]=0;
		key_data.NumUps[i]=0;
	}

	LEAVE_CRITICAL_SECTION( key_lock );	
}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:35,代码来源:key.cpp


注:本文中的LEAVE_CRITICAL_SECTION函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。