• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ LEAVE_CRITICAL_SECTION函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: sp_wait

void sp_wait( void ) 
{
	HAS_CRITICAL_SECTION;
	
	ENTER_CRITICAL_SECTION();
	CURRENT_TASK()->errno = 0;
	CURRENT_TASK()->status = TASK_WAITING;
	LEAVE_CRITICAL_SECTION();
}
开发者ID:nesl,项目名称:splt,代码行数:9,代码来源:sp_task.c


示例17: ker_pop_current_pid

void ker_pop_current_pid()
{
	HAS_CRITICAL_SECTION;
	ENTER_CRITICAL_SECTION();
	pid_sp--;
	ker_set_current_pid(*pid_sp);
	LEAVE_CRITICAL_SECTION();
	return;
}
开发者ID:nesl,项目名称:umpu,代码行数:9,代码来源:sched.c


示例18: mouse_eval_deltas

// change in mouse position since last call
void mouse_eval_deltas()
{
	static int old_x = 0;
	static int old_y = 0;
	int tmp_x, tmp_y, cx, cy;

	Mouse_dx = Mouse_dy = Mouse_dz = 0;
	if (!mouse_inited)
		return;

#ifdef WIN32
	if (Mouse_mode == MOUSE_MODE_DI) {
		mouse_eval_deltas_di();
		return;
	}
#endif

	cx = gr_screen.max_w / 2;
	cy = gr_screen.max_h / 2;

	ENTER_CRITICAL_SECTION( mouse_lock );

	POINT pnt;
	getWindowMousePos(&pnt);
	tmp_x = pnt.x;
	tmp_y = pnt.y;

	Mouse_dx = tmp_x - old_x;
	Mouse_dy = tmp_y - old_y;
	Mouse_dz = 0;

	// Speeds up the menu mouse on higher resolutions. The check for a
	// visible mouse should eliminate any possible gameplay changes.
	if ( mouse_is_visible() ) {
		gr_resize_screen_pos( &Mouse_dx, &Mouse_dy );
	}

	if (Keep_mouse_centered && Mouse_hidden) {
		if (Mouse_dx || Mouse_dy)
			mouse_force_pos(cx, cy);

		old_x = cx;
		old_y = cy;

	} else {
		old_x = tmp_x;
		old_y = tmp_y;
	}

	LEAVE_CRITICAL_SECTION( mouse_lock );

	//WMC - For On Mouse Moved trigger
	if(Mouse_dx != 0 || Mouse_dy != 0)
	{
		Script_system.RunCondition(CHA_MOUSEMOVED);
	}
}
开发者ID:Admiral-MS,项目名称:fs2open.github.com,代码行数:58,代码来源:mouse.cpp


示例19: ker_spi_read_data

/**
 * Read data from the spi
 */
int8_t ker_spi_read_data(
		uint8_t *sharedBuf,
		uint8_t rx_len,
		uint8_t rx_cnt,
		uint8_t calling_id) {
	HAS_CRITICAL_SECTION;

	if (s.state == SPI_SYS_IDLE) {  // not reserved
		return -EINVAL;
	}	

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

	// get a handle to users buffer
	if (rx_len >= MAX_SPI_READ_LEN) {
		return -EINVAL;
	} else {
		s.len = rx_len;
	}

	// need to assert CS pin
	if (s.flags & SPI_SYS_CS_HIGH_FLAG) {
		spi_cs_high(s.addr);
	} else {
		spi_cs_low(s.addr);
	}

	// only get/malloc a buffer if we are not currently in a DMA sequence
	if ((s.flags & SPI_SYS_SHARED_MEM_FLAG)) {
		if (NULL == sharedBuf) {
			return -EINVAL;
		} else {
			s.cnt = rx_cnt;
			s.bufPtr = sharedBuf;
			if (!(s.state == SPI_SYS_DMA_WAIT)) {
				s.usrBuf = sharedBuf;
			}
		}
	} else {
		// ignore value of sharedBuf
		if (NULL == (s.bufPtr = s.usrBuf = ker_malloc(s.len, SPI_PID))) {
			return -ENOMEM;
		} else {
			s.cnt = 1;
		}
	}

	ENTER_CRITICAL_SECTION();
	s.state = SPI_SYS_RX;
	LEAVE_CRITICAL_SECTION();
	
	return spi_masterRxData(s.usrBuf, s.len, s.flags);
}
开发者ID:nesl,项目名称:sos-2x,代码行数:59,代码来源:spi_system.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ LEDS_ON函数代码示例发布时间:2022-05-30
下一篇:
C++ LEAVE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap