tweak
[cdsspec-compiler.git] / benchmark / ms-queue / my_queue.h
index cc10de498e2f7317c8439a5a387fe2cd9a9faabf..2459b9cbba070f663cb4b5880087b219d3f812cb 100644 (file)
@@ -30,23 +30,41 @@ typedef struct {
 
 void init_queue(queue_t *q, int num_threads);
 
-#include <list>
-using namespace std;
 /**
        @Begin
        @Global_define:
                @DeclareStruct:
                typedef struct tag_elem {
-                       Tag id;
+                       call_id_t id;
                        unsigned int data;
                } tag_elem_t;
                
                @DeclareVar:
-               list<tag_elem_t> __queue;
-               Tag tag;
+               spec_list *__queue;
+               id_tag_t *tag;
                @InitVar:
-                       __queue = list<tag_elem_t>();
-                       tag = 1; // Beginning of available id
+                       __queue = new_spec_list();
+                       tag = new_id_tag(); // Beginning of available id
+               @DefineFunc:
+                       tag_elem_t* new_tag_elem(call_id_t id, unsigned int data) {
+                               tag_elem_t *e = (tag_elem_t*) malloc(sizeof(tag_elem_t));
+                               e->id = id;
+                               e->data = data;
+                               return e;
+                       }
+
+                       void free_tag_elem(tag_elem_t *e) {
+                               free(e);
+                       }
+
+                       call_id_t get_id(void *wrapper) {
+                               return ((tag_elem_t*) wrapper)->id;
+                       }
+
+                       unsigned int get_data(void *wrapper) {
+                               return ((tag_elem_t*) wrapper)->data;
+                       }
+
        @Happens_before:
                # Only check the happens-before relationship according to the id of the
                # commit_point_set. For commit_point_set that has same ID, A -> B means
@@ -61,14 +79,12 @@ using namespace std;
        @Begin
        @Interface: Enqueue
        @Commit_point_set: Enqueue_Success_Point
-       @ID: tag++
+       @ID: get_and_inc(tag);
        @Action:
                # __ID__ is an internal macro that refers to the id of the current
                # interface call
-               tag_elem_t elem;
-               elem.id = __ID__;
-               elem.data = val;
-               __queue.push_back(elem);
+               tag_elem_t elem = new_tag_elem(__ID__, val);
+               push_back(__queue, elem);
        @End
 */
 void enqueue(queue_t *q, unsigned int val);
@@ -77,10 +93,10 @@ void enqueue(queue_t *q, unsigned int val);
        @Begin
        @Interface: Dequeue
        @Commit_point_set: Dequeue_Success_Point
-       @ID: __queue.back().id
+       @ID: get_id(back(__queue))
        @Action:
-               unsigned int _Old_Val = __queue.front().data;
-               __queue.pop_front();
+               unsigned int _Old_Val = get_data(front(__queue));
+               pop_front(__queue);
        @Post_check:
                _Old_Val == __RET__
        @End