-/* Copyright (c) 2012-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-2023. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
static void broadcaster_send_file(const_broadcaster_t bc)
{
- int nb_pending_sends = 0;
-
for (unsigned int current_piece = 0; current_piece < bc->piece_count; current_piece++) {
XBT_DEBUG("Sending (send) piece %u from %s into mailbox %s", current_piece, sg_host_self_get_name(),
sg_mailbox_get_name(bc->first));
char* file_piece = bprintf("piece-%u", current_piece);
sg_comm_t comm = sg_mailbox_put_async(bc->first, file_piece, MESSAGE_SEND_DATA_HEADER_SIZE + PIECE_SIZE);
- bc->pending_sends[nb_pending_sends++] = comm;
+ sg_activity_set_push(bc->pending_sends, (sg_activity_t)comm);
}
- sg_comm_wait_all(bc->pending_sends, nb_pending_sends);
+ sg_activity_set_wait_all(bc->pending_sends);
}
static broadcaster_t broadcaster_init(sg_mailbox_t* mailboxes, unsigned int host_count, unsigned int piece_count)
bc->host_count = host_count;
bc->piece_count = piece_count;
bc->mailboxes = mailboxes;
- bc->pending_sends = xbt_malloc(sizeof(sg_comm_t) * MAX_PENDING_COMMS);
+ bc->pending_sends = sg_activity_set_init();
broadcaster_build_chain(bc);
static void broadcaster_destroy(broadcaster_t bc)
{
- free(bc->pending_sends);
- free(bc->mailboxes);
- free(bc);
+ sg_activity_set_delete(bc->pending_sends);
+ xbt_free(bc->mailboxes);
+ xbt_free(bc);
}
/** Emitter function */
{
XBT_DEBUG("broadcaster");
xbt_assert(argc > 2);
- unsigned int host_count = (unsigned int)xbt_str_parse_int(argv[1], "Invalid number of peers: %s");
+ unsigned int host_count = (unsigned int)xbt_str_parse_int(argv[1], "Invalid number of peers");
sg_mailbox_t* mailboxes = xbt_malloc(sizeof(sg_mailbox_t) * host_count);
free(name);
}
- unsigned int piece_count = (unsigned int)xbt_str_parse_int(argv[2], "Invalid number of pieces: %s");
+ unsigned int piece_count = (unsigned int)xbt_str_parse_int(argv[2], "Invalid number of pieces");
broadcaster_t bc = broadcaster_init(mailboxes, host_count, piece_count);