Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/builtin/builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ typedef struct $R $R;

struct $Actor;
struct $Catcher;
struct B_Msg;
typedef struct $Actor *$Actor;
typedef struct $Catcher *$Catcher;
typedef struct B_Msg *B_Msg;

#define $Lock volatile atomic_flag

Expand Down
6 changes: 3 additions & 3 deletions base/builtin/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct $actionG_class {
B_str (*__repr__)($action);
$R (*__call__)($action, $Cont, $WORD);
$R (*__exec__)($action, $Cont, $WORD);
B_Msg (*__asyn__)($action, $WORD);
B_Future (*__asyn__)($action, $WORD);
};
struct $action {
struct $actionG_class *$class;
Expand Down Expand Up @@ -118,7 +118,7 @@ struct $action2G_class {
B_str (*__repr__)($action2);
$R (*__call__)($action2, $Cont, $WORD, $WORD);
$R (*__exec__)($action2, $Cont, $WORD, $WORD);
B_Msg (*__asyn__)($action2, $WORD, $WORD);
B_Future (*__asyn__)($action2, $WORD, $WORD);
};
struct $action2 {
struct $action2G_class *$class;
Expand All @@ -138,7 +138,7 @@ struct $action3G_class {
B_str (*__repr__)($action3);
$R (*__call__)($action3, $Cont, $WORD, $WORD, $WORD);
$R (*__exec__)($action3, $WORD, $WORD, $WORD);
B_Msg (*__asyn__)($action3, $WORD, $WORD, $WORD);
B_Future (*__asyn__)($action3, $WORD, $WORD, $WORD);
};
struct $action3 {
struct $action3G_class *$class;
Expand Down
10 changes: 6 additions & 4 deletions base/builtin/registration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define BYTEARRAY_ID 12
#define BYTES_ID 13
#define ITEM_ID 14
#define MSG_ID 15
#define FUTURE_ID 15
Comment thread
plajjan marked this conversation as resolved.
#define ACTOR_ID 16
#define CATCHER_ID 17
#define SLICE_ID 18 // Adding SLICE_ID by using a gap in the numbering...
Expand Down Expand Up @@ -90,13 +90,15 @@
#define WEQNONE_ID 68
#define IDENTITYACTOR_ID 69

#define PREASSIGNED 72
#define MSG_ID 72 // transport envelope B_Msg (RTS-internal, see rts.h)

#define PREASSIGNED 73


/*
* Register the builtin classes (those with the above class id's except MSG_ID -- CONSTCONT_ID).
* Register the builtin classes (those with the above class id's except FUTURE_ID -- CONSTCONT_ID and MSG_ID).
* This must be the first registration call, since it also initializes the data structures containing the mapping.
* This call does *not* register the rts class id's MSG_ID -- CONSTCONT_ID, which must be registered by
* This call does *not* register the rts class id's FUTURE_ID -- CONSTCONT_ID and MSG_ID, which must be registered by
* a call to register_rts in rts.h.
*/

Expand Down
52 changes: 26 additions & 26 deletions base/rts/q.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,71 +136,71 @@ int ENQ_ready($Actor a) {
// return true if the queue was previously empty.
bool ENQ_msg(B_Msg m, $Actor a) {
bool did_enq = true;
spinlock_lock(&a->B_Msg_lock);
spinlock_lock(&a->$msg_lock);
m->$next = NULL;
if (a->B_Msg_tail) {
a->B_Msg_tail->$next = m;
a->B_Msg_tail = m;
if (a->$msg_tail) {
a->$msg_tail->$next = m;
a->$msg_tail = m;
did_enq = false;
} else {
a->B_Msg = m;
a->B_Msg_tail = m;
a->$msg = m;
a->$msg_tail = m;
}
spinlock_unlock(&a->B_Msg_lock);
spinlock_unlock(&a->$msg_lock);
return did_enq;
}

// Atomically dequeue the first message from the queue of actor "a",
// return true if the queue still holds messages.
bool DEQ_msg($Actor a) {
bool has_more = false;
spinlock_lock(&a->B_Msg_lock);
B_Msg x = a->B_Msg;
spinlock_lock(&a->$msg_lock);
B_Msg x = a->$msg;
if (x) {
a->B_Msg = x->$next;
a->$msg = x->$next;
x->$next = NULL;
if (a->B_Msg == NULL) {
a->B_Msg_tail = NULL;
if (a->$msg == NULL) {
a->$msg_tail = NULL;
}
has_more = a->B_Msg != NULL;
has_more = a->$msg != NULL;
} else {
a->B_Msg_tail = NULL;
a->$msg_tail = NULL;
}
spinlock_unlock(&a->B_Msg_lock);
spinlock_unlock(&a->$msg_lock);
return has_more;
}
#else // MSGQ == 1
// Atomically enqueue message "m" onto the queue of actor "a",
// return true if the queue was previously empty.
bool ENQ_msg(B_Msg m, $Actor a) {
bool did_enq = true;
spinlock_lock(&a->B_Msg_lock);
spinlock_lock(&a->$msg_lock);
m->$next = NULL;
if (a->B_Msg) {
B_Msg x = a->B_Msg;
if (a->$msg) {
B_Msg x = a->$msg;
while (x->$next)
x = x->$next;
x->$next = m;
did_enq = false;
} else {
a->B_Msg = m;
a->$msg = m;
}
spinlock_unlock(&a->B_Msg_lock);
spinlock_unlock(&a->$msg_lock);
return did_enq;
}

// Atomically dequeue the first message from the queue of actor "a",
// return true if the queue still holds messages.
bool DEQ_msg($Actor a) {
bool has_more = false;
spinlock_lock(&a->B_Msg_lock);
if (a->B_Msg) {
B_Msg x = a->B_Msg;
a->B_Msg = x->$next;
spinlock_lock(&a->$msg_lock);
if (a->$msg) {
B_Msg x = a->$msg;
a->$msg = x->$next;
x->$next = NULL;
has_more = a->B_Msg != NULL;
has_more = a->$msg != NULL;
}
spinlock_unlock(&a->B_Msg_lock);
spinlock_unlock(&a->$msg_lock);
return has_more;
}
#endif // MSGQ
Loading
Loading