示例#1
0
文件: os.c 项目: jeffplourde/cortex
/* ::cortex::os::sleep(uint32 sec,uint32 nsec) */
cx_void os_sleep(cx_uint32 sec, cx_uint32 nsec) {
/* $begin(::cortex::os::sleep) */

    cx_sleep(sec, nsec);

/* $end */
}
示例#2
0
/* $end */
cx_void web_server_post(web_server _this, cx_event e) {
/* $begin(::cortex::web::server::post) */
    cx_uint32 size = 0;
    cx_observableEvent e2;

    cx_lock(_this);
    /* Check if there is already another event in the queue for the same object.
     * if so, replace event with latest update. */
    if ((e2 = web_server_findRelatedEvent(_this, cx_observableEvent(e)))) {
        cx_llReplace(_this->events, e2, e);
        cx_free(e2);
    } else {
        cx_llAppend(_this->events, e);
    }
    size = cx_llSize(_this->events);
    cx_unlock(_this);

    /* If queue is getting big, slow down publisher */
    if (size > 100) {
        cx_sleep(0, 10000000);
    }

/* $end */
}