コード例 #1
0
ファイル: init.c プロジェクト: mitghi/CSpider
cspider_t *init_cspider() {
  cspider_t *spider = (cspider_t *)malloc(sizeof(cspider_t));
  PANIC(spider);
  //init task queue
  spider->task_queue = initTaskQueue();
  PANIC(spider->task_queue);
  spider->task_queue_doing = initTaskQueue();
  PANIC(spider->task_queue_doing);
  //init data queue
  spider->data_queue = initDataQueue();
  PANIC(spider->data_queue);
  spider->data_queue_doing = initDataQueue();
  PANIC(spider->data_queue_doing);
  
  spider->threadpool_size = 4;
  spider->process = NULL;
  spider->save = NULL;
  spider->process_user_data = NULL;
  spider->save_user_data = NULL;
  spider->loop = uv_default_loop();
  
  spider->idler = (uv_idle_t*)malloc(sizeof(uv_idle_t));
  spider->lock = (uv_rwlock_t*)malloc(sizeof(uv_rwlock_t));
  uv_rwlock_init(spider->lock);
  spider->save_lock = (uv_rwlock_t*)malloc(sizeof(uv_rwlock_t));
  uv_rwlock_init(spider->save_lock);
  spider->idler->data = spider;
  spider->site = (site_t*)malloc(sizeof(site_t));
  spider->site->user_agent = NULL;
  spider->site->proxy = NULL;
  spider->site->cookie = NULL;
  spider->site->timeout = 0;
  spider->log = NULL;
  spider->bloom = init_Bloom();
  return spider;
}
コード例 #2
0
ファイル: rtos.c プロジェクト: dek-an/Micro
// //////////////////////////////////////////////////////////
// Interface Implementation
//
void initRtos(void)
{
	INITIALIZE_CHECKING();

	initTaskQueue();
	initTimerTaskSet();

	// set timer TC0
	// Clear Timer on Compare match; WGM01:0 = 10
	// prescaler 64; CS02:0 = 011
	TCCR0 = SFT(WGM01) | SFT(CS01) | SFT(CS00);
	// reset counter
	TCNT0 = 0;
	// set Output Compare Register value
	OCR0 = RTOS_TIMER_OCR;
	// Output Compare Math Interrupt Enable
	SBI(TIMSK, OCIE0);
}