14IdrisMutex** idris_ms = NULL;
21 pthread_mutex_init(&m, NULL);
22 IdrisMutex* newm = EMALLOC(sizeof(IdrisMutex));
25 // Increase space for the mutexes
27 idris_ms = (IdrisMutex**)EMALLOC(sizeof(IdrisMutex*));
30 idris_ms = (IdrisMutex**)(EREALLOC(idris_ms, sizeof(IdrisMutex*)*(idris_mutexes+1)));
34 idris_ms[idris_mutexes-1] = newm;
35 return idris_mutexes-1;
38void idris_doLock(int lock)
40 pthread_mutex_lock(&(idris_ms[lock]->m_id));
43void idris_doUnlock(int lock)
45 pthread_mutex_unlock(&(idris_ms[lock]->m_id));
48struct idris_threadinfo {
53void* idris_runThread(void* th_in) {
54 printf("IN THREAD\n");
55 struct idris_threadinfo* th = (struct idris_threadinfo*)th_in;
56 printf("using %d\n", th_in);
57 void* v = DO_EVAL(th_in, 1);
62void idris_doFork(void* proc)
65 pthread_t* t = malloc(sizeof(pthread_t));
66 struct idris_threadinfo th;
67 printf("in %d\n", proc);
70 pthread_create(t, NULL, idris_runThread, proc);
74void* idris_doWithin(int limit, void* proc, void* doOnFail)
76 pthread_t* t = EMALLOC(sizeof(pthread_t));
77// printf("CREATING THREAD %d\n", t);
78 struct idris_threadinfo th;
83 gettimeofday(&tv, NULL);
84 int tnow, tthen = do_utime();
86 pthread_create(t, NULL, idris_runThread, &th);
87// printf("tthen %d\n", tthen);
93 // If the answer has been updated, we're done.
94 if (th.result!=NULL) {
95 pthread_join(*t, &ans);
98 gettimeofday(&tv, NULL);
101// printf("tnow %d\n", tnow);
103 while(tnow<(tthen+(limit*1000)));
105 return DO_EVAL(doOnFail,1);
110 gettimeofday(&tv, NULL);
113 if (start==0) { start = tv.tv_sec; }
115 return 1000000*(tv.tv_sec - start)+tv.tv_usec;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list