feature request: an atomicAdd() function included in gwan.h

后端 未结 2 1843
感动是毒
感动是毒 2021-01-16 01:18

In the G-WAN KV options, KV_INCR_KEY will use the 1st field as the primary key.

That means there is a function which increments atomically already built

2条回答
  •  猫巷女王i
    2021-01-16 01:44

    Thanks for Gil's helpful guidance.
    Now, I can do it by myself.
    I change the code in persistence.c, as below:
    firstly, i changed the definition of val in data to volatile.

    //data[0]->val++;  
    //xbuf_xcat(reply, "Value: %d", data[0]->val);  
    int new_count, loops=50000000, time1, time2, time;  
    
    time1=getus();
    for(int i; ival, 1);
    }
    time2=getus();
    
    time=loops/(time2-time1);
    time=time*1000;
    
    xbuf_xcat(reply, "Value: %d, time: %d incr_ops/msec", new_count, time);
    

    I got 52,000 incr_operations/msec with my old E2180 CPU.
    So, with GCC compiler I can do it by myself.
    thanks again.

提交回复
热议问题