当前位置: 首页>>代码示例>>C++>>正文


C++ Mail::alloc方法代码示例

本文整理汇总了C++中Mail::alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ Mail::alloc方法的具体用法?C++ Mail::alloc怎么用?C++ Mail::alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mail的用法示例。


在下文中一共展示了Mail::alloc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: line_coding_changed_cb

void line_coding_changed_cb(int baud, int bits, int parity, int stop)
{
    line_coding_t *lc = lc_mail.alloc();
    lc->baud = baud;
    lc->bits = bits;
    lc->parity = parity;
    lc->stop = stop;
    lc_mail.put(lc);
}
开发者ID:0xc0170,项目名称:mbed,代码行数:9,代码来源:main.cpp

示例2: test_mail_full

/** Test mail empty

    Given a mail of uint32_t data with size of 1
    before data is inserted the mail shouldn't be full
    after data is inserted the mail should be full
 */
void test_mail_full()
{
    Mail<mail_t, 1> m;

    mail_t *mail = m.alloc();

    TEST_ASSERT_EQUAL(false,  m.full());

    m.put(mail);

    TEST_ASSERT_EQUAL(true, m.full());
}
开发者ID:betzw,项目名称:mbed,代码行数:18,代码来源:main.cpp

示例3: send_thread

void send_thread (void const *argument) {
    uint32_t i = 0;
    while (true) {
        i++; // fake data update
        mail_t *mail = mail_box.alloc();
        mail->voltage = (i * 0.1) * 33; 
        mail->current = (i * 0.1) * 11;
        mail->counter = i;
        mail_box.put(mail);
        Thread::wait(1000);
    }
}
开发者ID:3eggert,项目名称:mbed,代码行数:12,代码来源:main.cpp

示例4: send_thread

void send_thread (void const *argument) {
    static uint32_t i = 10;
    while (true) {
        i++; // fake data update
        mail_t *mail = mail_box.alloc();
        mail->voltage = CREATE_VOLTAGE(i);
        mail->current = CREATE_CURRENT(i);
        mail->counter = i;
        mail_box.put(mail);
        Thread::wait(QUEUE_PUT_DELAY);
    }
}
开发者ID:AlessandroA,项目名称:mbed,代码行数:12,代码来源:main.cpp

示例5: sendToMail

// Send speed, accelerometer and brake values to a 100 element MAIL queue
// car mail semaphore used to protect messages
// average speed and input semphore used to fix vales
// Repetition rate 0.2 Hz = 5 seconds
void sendToMail(void const *args){
    while(true){
        mail_t *mail = mail_box.alloc();
        CAR_MAIL_SEM.wait();

        AVR_SPEED_SEM.wait();
        mail->speedVal = averageSpeed; 
        AVR_SPEED_SEM.release();
        
        INPUT_SEM.wait();
        mail->accelerometerVal = accelerationValue;
        mail->breakVal = brakeValue;
        INPUT_SEM.release();
        
        write++;        
       
        mail_box.put(mail);
                
        CAR_MAIL_SEM.release();
                
        Thread::wait(5000);  
    }
}
开发者ID:rm32,项目名称:Lab3,代码行数:27,代码来源:main.cpp

示例6: adcISR

// Call this on precise intervals
void adcISR() {

    
    //Read sample - make a copy
    float sample = adcIn;
    //Grab switch state
    uint32_t switch1State = sw1;
    uint32_t switch2State = sw2;
    
    //Allocate a block from the memory pool
    message_t *message = mail_box.alloc();
    if (message == NULL) {
        //Out of memory
        printf("Out of memory\n\r");
        redLED = 1;
        return;   
    }
    
    //Fill in the data
    message->adcValue = sample;
    message->sw1State = switch1State;
    message->sw2State = switch2State;
    
    //Write to queue
    osStatus stat = mail_box.put(message);    //Note we are sending the "pointer"
    
    //Check if succesful
    if (stat == osErrorResource) {
        redLED = 1; 
        printf("queue->put() Error code: %4Xh, Resource not available\r\n", stat);   
        mail_box.free(message);
        return;
    }
    
    
}
开发者ID:SoCM,项目名称:ELEC143,代码行数:37,代码来源:main.cpp


注:本文中的Mail::alloc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。