Ejemplo n.º 1
0
void
keyboardthread(void *)
{
	Rune r;
	Timer *timer;
	Text *t;
	enum { KTimer, KKey, NKALT };
	static Alt alts[NKALT+1];

	alts[KTimer].c = nil;
	alts[KTimer].v = nil;
	alts[KTimer].op = CHANNOP;
	alts[KKey].c = keyboardctl->c;
	alts[KKey].v = &r;
	alts[KKey].op = CHANRCV;
	alts[NKALT].op = CHANEND;

	timer = nil;
	typetext = nil;
	threadsetname("keyboardthread");
	for(;;){
		switch(alt(alts)){
		case KTimer:
			timerstop(timer);
			t = typetext;
			if(t!=nil && t->what==Tag){
				winlock(t->w, 'K');
				wincommit(t->w, t);
				winunlock(t->w);
				flushimage(display, 1);
			}
			alts[KTimer].c = nil;
			alts[KTimer].op = CHANNOP;
			break;
		case KKey:
		casekeyboard:
			typetext = rowtype(&row, r, mouse->xy);
			t = typetext;
			if(t!=nil && t->col!=nil && !(r==Kdown || r==Kleft || r==Kright))	/* scrolling doesn't change activecol */
				activecol = t->col;
			if(t!=nil && t->w!=nil)
				t->w->body.file->curtext = &t->w->body;
			if(timer != nil)
				timercancel(timer);
			if(t!=nil && t->what==Tag) {
				timer = timerstart(500);
				alts[KTimer].c = timer->c;
				alts[KTimer].op = CHANRCV;
			}else{
				timer = nil;
				alts[KTimer].c = nil;
				alts[KTimer].op = CHANNOP;
			}
			if(nbrecv(keyboardctl->c, &r) > 0)
				goto casekeyboard;
			flushimage(display, 1);
			break;
		}
	}
}
Ejemplo n.º 2
0
void benchrenderpage(fz_context *ctx, pdf_document *xref, pdf_page *page, int pagenum)
{
	fz_device *dev;
	fz_pixmap *pix;
	fz_bbox bbox;
	mstimer timer;

	timerstart(&timer);

	bbox = fz_round_rect(pdf_bound_page(xref, page));
	pix = fz_new_pixmap_with_bbox(ctx, fz_device_rgb, bbox);
	fz_clear_pixmap_with_value(ctx, pix, 0xFF);
	dev = fz_new_draw_device(ctx, pix);
	fz_try(ctx) {
		pdf_run_page(xref, page, dev, fz_identity, NULL);
		timerstop(&timer);
		logbench("pagerender %3d: %.2f ms\n", pagenum, timeinms(&timer));
	}
	fz_catch(ctx) {
		logbench("Error: pdf_run_page() failed\n");
	}

	fz_drop_pixmap(ctx, pix);
	fz_free_device(dev);
}
Ejemplo n.º 3
0
void rt_finalize(void) {
    timerstart();
    if(global_usegraphics)
        do { rt_sleep(10); timerstop(); }
        while(timertime() < 10 && video->next_frame());
#ifdef _WINDOWS
    else rt_sleep(10000);
#endif
}
Ejemplo n.º 4
0
Archivo: main.c Proyecto: 99years/plan9
void
keyboardthread(void *)
{
	Timer *timer;
	Text *t;
	Rune r;

	static Alt alts[NKALT+1];

	alts[KTimer].c = nil;
	alts[KTimer].v = nil;
	alts[KTimer].op = CHANNOP;
	alts[KKey].c = keyboardctl->c;
	alts[KKey].v = &r;
	alts[KKey].op = CHANRCV;
	alts[NKALT].op = CHANEND;

	timer = nil;
	threadsetname("keyboardthread");
	for(;;){
		switch(alt(alts)){
		case KTimer:
			timerstop(timer);
			alts[KTimer].c = nil;
			alts[KTimer].op = CHANNOP;
			break;
		case KKey:
		casekeyboard:
			typetext = rowwhich(&row, mouse->xy, r, TRUE);
			t = typetext;
			if(t!=nil && t->col!=nil &&
			    !(r==Kdown || r==Kleft || r==Kright))
				/* scrolling doesn't change activecol */
				activecol = t->col;
			if(timer != nil)
				timercancel(timer);
			if(t!=nil){
				texttype(t, r);
				timer = timerstart(500);
				alts[KTimer].c = timer->c;
				alts[KTimer].op = CHANRCV;
			}else{
				timer = nil;
				alts[KTimer].c = nil;
				alts[KTimer].op = CHANNOP;
			}
			if(nbrecv(keyboardctl->c, &r) > 0)
				goto casekeyboard;
			flushimage(display, 1);
			break;
		}
	}
}
Ejemplo n.º 5
0
main_module::main_module(potoc_sun &sun_p, drain_parametrs_solar_battery &drain_p,drain_position_salleter & position)
{
    position_salleter_potoc=&position;
    sun_potoc=&sun_p;
    drain=&drain_p;
    QObject::connect(this,SIGNAL(stop_sun_signal()),sun_potoc,SLOT(timerstop()));
    QObject::connect(this,SIGNAL(start_sun_signal()),sun_potoc,SLOT(timerstart()));
    QObject::connect(this,SIGNAL(qdebug_sun_signal(bool)),sun_potoc,SLOT(debug(bool)));
    QObject::connect(this,SIGNAL(replay_sun_signal(int)),sun_potoc,SLOT(upreplay(int)));
    qdebug=setting_f.Get_qdebug_main_modul();

}
Ejemplo n.º 6
0
 void on_process()
 {
     char buf[128];
     flt runtime;
     timerstart();
     rt_renderscene(global_scene);
     timerstop();
     runtime=timertime();
     sprintf(buf, "\nCPU Time: %.3f seconds.", runtime);
     rt_ui_message(MSG_0, buf); buf[0] = ' ';
     strcat(global_window_title, buf);
     title = global_window_title; updating = true;
     show_title();
     rt_finalize();
 }
Ejemplo n.º 7
0
void
plumbthread(void *v)
{
	CFid *fid;
	Plumbmsg *m;
	Timer *t;

	USED(v);
	threadsetname("plumbproc");
	
	/*
	 * Loop so that if plumber is restarted, acme need not be.
	 */
	for(;;){
		/*
		 * Connect to plumber.
		 */
		plumbunmount();
		while((fid = plumbopenfid("edit", OREAD|OCEXEC)) == nil){
			t = timerstart(2000);
			recv(t->c, nil);
			timerstop(t);
		}
		plumbeditfid = fid;
		plumbsendfid = plumbopenfid("send", OWRITE|OCEXEC);
	
		/*
		 * Relay messages.
		 */
		for(;;){
			m = plumbrecvfid(plumbeditfid);
			if(m == nil)
				break;
			sendp(cplumb, m);
		}

		/*
		 * Lost connection.
		 */
		fid = plumbsendfid;
		plumbsendfid = nil;
		fsclose(fid);

		fid = plumbeditfid;
		plumbeditfid = nil;
		fsclose(fid);
	}
}
Ejemplo n.º 8
0
void benchfile(char *pdffilename, int loadonly, int pageNo)
{
	pdf_document *xref = NULL;
	mstimer timer;
	int page_count;
	int curpage;

	fz_context *ctx = fz_new_context(NULL, NULL, FZ_STORE_DEFAULT);
	if (!ctx) {
		logbench("Error: fz_new_context() failed\n");
		return;
	}

	logbench("Starting: %s\n", pdffilename);
	timerstart(&timer);
	fz_var(xref);
	fz_try(ctx) {
		xref = openxref(ctx, pdffilename);
	}
	fz_catch(ctx) {
		goto Exit;
	}
	timerstop(&timer);
	logbench("load: %.2f ms\n", timeinms(&timer));

	page_count = pdf_count_pages(xref);
	logbench("page count: %d\n", page_count);

	if (loadonly)
		goto Exit;
	for (curpage = 1; curpage <= page_count; curpage++) {
		pdf_page *page;
		if ((-1 != pageNo) && (pageNo != curpage))
			continue;
		page = benchloadpage(ctx, xref, curpage);
		if (page) {
			benchrenderpage(ctx, xref, page, curpage);
			pdf_free_page(xref, page);
		}
	}

Exit:
	logbench("Finished: %s\n", pdffilename);
	pdf_close_document(xref);
	fz_free_context(ctx);
}
Ejemplo n.º 9
0
pdf_page *benchloadpage(fz_context *ctx, pdf_document *xref, int pagenum)
{
	pdf_page *page = NULL;
	mstimer timer;

	timerstart(&timer);
	fz_try(ctx) {
		page = pdf_load_page(xref, pagenum - 1);
	}
	fz_catch(ctx) {
		logbench("Error: failed to load page %d\n", pagenum);
		return NULL;
	}
	timerstop(&timer);
	logbench("pageload   %3d: %.2f ms\n", pagenum, timeinms(&timer));

	return page;
}
Ejemplo n.º 10
0
void testgeoipcountry(int flags, const char *msg, int numlookups)
{
    const char *str = NULL;
    double t = 0;
    int i4 = 0;
    int i2 = 0;
    GeoIP *i = NULL;
    i = GeoIP_open("/usr/local/share/GeoIP/GeoIP.dat", flags);
    if (i == NULL) {
        printf("error: GeoIP.dat does not exist\n");
        return;
    }
    timerstart();
    for (i2 = 0; i2 < numlookups; i2++) {
        str = GeoIP_country_name_by_addr(i, ipstring[i4]);
        i4 = (i4 + 1) % numipstrings;
    }
    t = timerstop();
    printf("%s\n", msg);
    printf("%d lookups made in %f seconds \n", numlookups, t);
    GeoIP_delete(i);
}