// Queue MIDI event int MIDIQ::eventEnQ(queueEvent *e) { // Allocate a new event from the heap int newP = allocEvent(); // If none left, return error if (0 != newP) { // Else use the allocated event to enqueue this midi event queue[newP] = *e; int prev = 0; int ptr = queueHead; while (0 != ptr) { if (((queue[ptr].beat > (*e).beat)) || ((queue[ptr].beat == (*e).beat) && (queue[ptr].tick >= (*e).tick))) break; prev = ptr; ptr = queue[ptr].next; } if (ptr == queueHead) { queue[newP].next = queueHead; queueHead = newP; } else { queue[newP].next = ptr; queue[prev].next = newP; } } return newP; }
////////////////////////////////////////////////////////////////////////// // instantEvent //virtual void SysProfilerChromeTracing::instantEvent( const std::string& Tag ) { if( ProfilingActive_ == 1 ) { // New section. TProfilerEvent* Event = allocEvent(); if( Event != nullptr ) { // Setup section. Event->Tag_ = Tag; Event->Type_ = "I"; Event->ThreadId_ = BcCurrentThreadId(); Event->StartTime_ = Timer_.time(); } } }
static foreign_t alarm4_gen(time_abs_rel abs_rel, term_t time, term_t callable, term_t id, term_t options) { Event ev; double t; module_t m = NULL; unsigned long flags = 0L; if ( options ) { term_t tail = PL_copy_term_ref(options); term_t head = PL_new_term_ref(); while( PL_get_list(tail, head, tail) ) { atom_t name; int arity; if ( PL_get_name_arity(head, &name, &arity) ) { if ( arity == 1 ) { term_t arg = PL_new_term_ref(); _PL_get_arg(1, head, arg); if ( name == ATOM_remove ) { int t = FALSE; if ( !pl_get_bool_ex(arg, &t) ) return FALSE; if ( t ) flags |= EV_REMOVE; } else if ( name == ATOM_install ) { int t = TRUE; if ( !pl_get_bool_ex(arg, &t) ) return FALSE; if ( !t ) flags |= EV_NOINSTALL; } } } } if ( !PL_get_nil(tail) ) return pl_error(NULL, 0, NULL, ERR_ARGTYPE, 4, options, "list"); } if ( !PL_get_float(time, &t) ) return pl_error(NULL, 0, NULL, ERR_ARGTYPE, 1, time, "number"); if ( !(ev = allocEvent()) ) return FALSE; if (abs_rel==TIME_REL) setTimeEvent(ev, t); else setTimeEventAbs(ev,t); if ( !unify_timer(id, ev) ) { freeEvent(ev); /* not linked: no need to lock */ return FALSE; } ev->flags = flags; PL_strip_module(callable, &m, callable); ev->module = m; ev->goal = PL_record(callable); if ( !(ev->flags & EV_NOINSTALL) ) { int rc; if ( (rc=installEvent(ev)) != TRUE ) { freeEvent(ev); /* not linked: no need to lock */ return alarm_error(id, rc); } } return TRUE; }