Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please consider the following formatting changes to #13529 #302

Open
wants to merge 1 commit into
base: pr13529
Choose a base branch
from
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
14 changes: 7 additions & 7 deletions Framework/Core/src/CommonServices.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,16 @@ o2::framework::ServiceSpec
O2_SIGNPOST_EVENT_EMIT(data_processor_context, cid, "oldest_possible_timeslice", "Queueing oldest possible timeslice %" PRIu64 " propagation for execution.",
(uint64_t)oldestPossibleOutput.timeslice.value);
AsyncQueueHelpers::post(
queue, AsyncTask{ .timeslice = TimesliceId{oldestPossibleTimeslice},
.id = decongestion.oldestPossibleTimesliceTask,
.debounce = -1, .callback = decongestionCallback}
.user<DecongestionContext>(DecongestionContext{.ref = services, .oldestPossibleOutput = oldestPossibleOutput}));
queue, AsyncTask{.timeslice = TimesliceId{oldestPossibleTimeslice},
.id = decongestion.oldestPossibleTimesliceTask,
.debounce = -1,
.callback = decongestionCallback}
.user<DecongestionContext>(DecongestionContext{.ref = services, .oldestPossibleOutput = oldestPossibleOutput}));

if (decongestion.orderedCompletionPolicyActive) {
AsyncQueueHelpers::post(
queue, AsyncTask{.timeslice = TimesliceId{oldestPossibleOutput.timeslice.value},.id = decongestion.oldestPossibleTimesliceTask, .debounce = -1,
.callback = decongestionCallbackOrdered}
.user<DecongestionContext>({.ref = services, .oldestPossibleOutput = oldestPossibleOutput}));
queue, AsyncTask{.timeslice = TimesliceId{oldestPossibleOutput.timeslice.value}, .id = decongestion.oldestPossibleTimesliceTask, .debounce = -1, .callback = decongestionCallbackOrdered}
.user<DecongestionContext>({.ref = services, .oldestPossibleOutput = oldestPossibleOutput}));
} },
.kind = ServiceKind::Serial};
}
Expand Down
23 changes: 14 additions & 9 deletions Framework/Foundation/3rdparty/x9/examples/x9_example_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@ typedef struct {
int sum;
} msg;

static int random_int(int const min, int const max) {
static int random_int(int const min, int const max)
{
return min + rand() / (RAND_MAX / (max - min + 1) + 1);
}

static inline void fill_msg_1(msg* const msg) {
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
static inline void fill_msg_1(msg* const msg)
{
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
msg->sum = msg->a + msg->b;
}

static void* producer_fn(void* args) {
static void* producer_fn(void* args)
{
th_struct* data = (th_struct*)args;

msg m = {0};
Expand All @@ -68,7 +71,8 @@ static void* producer_fn(void* args) {
return 0;
}

static void* consumer_fn(void* args) {
static void* consumer_fn(void* args)
{
th_struct* data = (th_struct*)args;

msg m = {0};
Expand All @@ -79,7 +83,8 @@ static void* consumer_fn(void* args) {
return 0;
}

int main(void) {
int main(void)
{
/* Seed random generator */
srand((uint32_t)time(0));

Expand All @@ -90,11 +95,11 @@ int main(void) {
assert(x9_inbox_is_valid(inbox));

/* Producer */
pthread_t producer_th = {0};
pthread_t producer_th = {0};
th_struct producer_struct = {.inbox = inbox};

/* Consumer */
pthread_t consumer_th = {0};
pthread_t consumer_th = {0};
th_struct consumer_struct = {.inbox = inbox};

/* Launch threads */
Expand Down
47 changes: 27 additions & 20 deletions Framework/Foundation/3rdparty/x9/examples/x9_example_2.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,29 @@ typedef struct {
int product;
} msg_type_2;

static inline int random_int(int const min, int const max) {
static inline int random_int(int const min, int const max)
{
return min + rand() / (RAND_MAX / (max - min + 1) + 1);
}

static inline void fill_msg_type_1(msg_type_1 msg[const static 1]) {
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
static inline void fill_msg_type_1(msg_type_1 msg[const static 1])
{
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
msg->sum = msg->a + msg->b;
}

static inline void fill_msg_type_2(msg_type_2 to[const static 1],
msg_type_1 const from[const static 1]) {
to->x = from->a;
to->y = from->b;
to->sum = from->sum;
static inline void fill_msg_type_2(msg_type_2 to[const static 1],
msg_type_1 const from[const static 1])
{
to->x = from->a;
to->y = from->b;
to->sum = from->sum;
to->product = (from->a * from->b);
}

static void* producer_fn(void* args) {
static void* producer_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const destination = x9_select_inbox_from_node(data->node, "ibx_1");
Expand All @@ -99,7 +103,8 @@ static void* producer_fn(void* args) {
return 0;
}

static void* producer_consumer_fn(void* args) {
static void* producer_consumer_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const inbox = x9_select_inbox_from_node(data->node, "ibx_1");
Expand All @@ -122,7 +127,8 @@ static void* producer_consumer_fn(void* args) {
return 0;
}

static void* consumer_fn(void* args) {
static void* consumer_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const inbox = x9_select_inbox_from_node(data->node, "ibx_2");
Expand All @@ -139,41 +145,42 @@ static void* consumer_fn(void* args) {
return 0;
}

int main(void) {
int main(void)
{
/* Seed random generator */
srand((uint32_t)time(0));

/* Create inboxes */
x9_inbox* const inbox_msg_type_1 =
x9_create_inbox(4, "ibx_1", sizeof(msg_type_1));
x9_create_inbox(4, "ibx_1", sizeof(msg_type_1));

x9_inbox* const inbox_msg_type_2 =
x9_create_inbox(4, "ibx_2", sizeof(msg_type_2));
x9_create_inbox(4, "ibx_2", sizeof(msg_type_2));

/* Using asserts to simplify code for presentation purpose. */
assert(x9_inbox_is_valid(inbox_msg_type_1));
assert(x9_inbox_is_valid(inbox_msg_type_2));

/* Create node */
x9_node* const node =
x9_create_node("my_node", 2, inbox_msg_type_1, inbox_msg_type_2);
x9_create_node("my_node", 2, inbox_msg_type_1, inbox_msg_type_2);

/* Assert - Same reason as above. */
assert(x9_node_is_valid(node));

/* Producers */
pthread_t producer_th_1 = {0};
pthread_t producer_th_1 = {0};
th_struct producer_1_struct = {.node = node};

pthread_t producer_th_2 = {0};
pthread_t producer_th_2 = {0};
th_struct producer_2_struct = {.node = node};

/* Producer/Consumer */
pthread_t producer_consumer_th = {0};
th_struct prod_cons_struct = {.node = node};
th_struct prod_cons_struct = {.node = node};

/* Consumer */
pthread_t consumer_th = {0};
pthread_t consumer_th = {0};
th_struct consumer_struct = {.node = node};

/* Launch threads */
Expand Down
39 changes: 23 additions & 16 deletions Framework/Foundation/3rdparty/x9/examples/x9_example_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,32 @@ typedef struct {
double product;
} msg_type_2;

static inline int random_int(int const min, int const max) {
static inline int random_int(int const min, int const max)
{
return min + rand() / (RAND_MAX / (max - min + 1) + 1);
}

static inline double random_double(int const min, int const max) {
static inline double random_double(int const min, int const max)
{
return ((double)(random_int(min, max) * 1.0));
}

static inline void fill_msg_type_1(msg_type_1* const msg) {
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
static inline void fill_msg_type_1(msg_type_1* const msg)
{
msg->a = random_int(0, 10);
msg->b = random_int(0, 10);
msg->sum = msg->a + msg->b;
}

static inline void fill_msg_type_2(msg_type_2* const msg) {
msg->x = random_double(0, 10);
msg->y = random_double(0, 10);
static inline void fill_msg_type_2(msg_type_2* const msg)
{
msg->x = random_double(0, 10);
msg->y = random_double(0, 10);
msg->product = msg->x * msg->y;
}

static void* producer_1_fn(void* args) {
static void* producer_1_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const write_inbox = x9_select_inbox_from_node(data->node, "ibx_1");
Expand Down Expand Up @@ -122,7 +127,8 @@ static void* producer_1_fn(void* args) {
return 0;
}

static void* producer_2_fn(void* args) {
static void* producer_2_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const write_inbox = x9_select_inbox_from_node(data->node, "ibx_2");
Expand Down Expand Up @@ -161,34 +167,35 @@ static void* producer_2_fn(void* args) {
return 0;
}

int main(void) {
int main(void)
{
/* Seed random generator */
srand((uint32_t)time(0));

/* Create inboxes */
x9_inbox* const inbox_msg_type_1 =
x9_create_inbox(4, "ibx_1", sizeof(msg_type_1));
x9_create_inbox(4, "ibx_1", sizeof(msg_type_1));

x9_inbox* const inbox_msg_type_2 =
x9_create_inbox(4, "ibx_2", sizeof(msg_type_2));
x9_create_inbox(4, "ibx_2", sizeof(msg_type_2));

/* Using asserts to simplify code for presentation purpose. */
assert(x9_inbox_is_valid(inbox_msg_type_1));
assert(x9_inbox_is_valid(inbox_msg_type_2));

/* Create node */
x9_node* const node =
x9_create_node("my_node", 2, inbox_msg_type_1, inbox_msg_type_2);
x9_create_node("my_node", 2, inbox_msg_type_1, inbox_msg_type_2);

/* Asserts - Same reason as above.*/
assert(x9_node_is_valid(node));

/* Producer 1 (left on diagram) */
pthread_t producer_1_th = {0};
pthread_t producer_1_th = {0};
th_struct producer_1_struct = {.node = node};

/* Producer 2 (right on diagram) */
pthread_t producer_2_th = {0};
pthread_t producer_2_th = {0};
th_struct producer_2_struct = {.node = node};

/* Launch threads */
Expand Down
37 changes: 21 additions & 16 deletions Framework/Foundation/3rdparty/x9/examples/x9_example_4.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

typedef struct {
x9_node* node;
char* inbox_to_consume_from;
char* inbox_to_consume_from;
} th_struct;

typedef struct {
Expand All @@ -62,17 +62,20 @@ typedef struct {
int sum;
} msg;

static inline int random_int(int const min, int const max) {
static inline int random_int(int const min, int const max)
{
return min + rand() / (RAND_MAX / (max - min + 1) + 1);
}

static inline void fill_msg_type(msg* const m) {
m->a = random_int(0, 10);
m->b = random_int(0, 10);
static inline void fill_msg_type(msg* const m)
{
m->a = random_int(0, 10);
m->b = random_int(0, 10);
m->sum = m->a + m->b;
}

static void* producer_fn(void* args) {
static void* producer_fn(void* args)
{
th_struct* data = (th_struct*)args;

msg m = {0};
Expand All @@ -83,11 +86,12 @@ static void* producer_fn(void* args) {
return 0;
}

static void* consumer_fn(void* args) {
static void* consumer_fn(void* args)
{
th_struct* data = (th_struct*)args;

x9_inbox* const inbox =
x9_select_inbox_from_node(data->node, data->inbox_to_consume_from);
x9_select_inbox_from_node(data->node, data->inbox_to_consume_from);
assert(x9_inbox_is_valid(inbox));

msg m = {0};
Expand All @@ -99,7 +103,8 @@ static void* consumer_fn(void* args) {
return 0;
}

int main(void) {
int main(void)
{
/* Seed random generator */
srand((uint32_t)time(0));

Expand All @@ -121,21 +126,21 @@ int main(void) {
assert(x9_node_is_valid(node));

/* Producer */
pthread_t producer_th = {0};
pthread_t producer_th = {0};
th_struct producer_struct = {.node = node};

/* Consumer 1 */
pthread_t consumer_1_th = {0};
th_struct consumer_1_struct = {.node = node,
pthread_t consumer_1_th = {0};
th_struct consumer_1_struct = {.node = node,
.inbox_to_consume_from = "ibx_1"};
/* Consumer 2 */
pthread_t consumer_2_th = {0};
th_struct consumer_2_struct = {.node = node,
pthread_t consumer_2_th = {0};
th_struct consumer_2_struct = {.node = node,
.inbox_to_consume_from = "ibx_2"};

/* Consumer 3 */
pthread_t consumer_3_th = {0};
th_struct consumer_3_struct = {.node = node,
pthread_t consumer_3_th = {0};
th_struct consumer_3_struct = {.node = node,
.inbox_to_consume_from = "ibx_3"};

/* Launch threads */
Expand Down
Loading
Loading