Skip to content

Commit

Permalink
HG Core: make HG_Core_event_ready() non-inline to fix NA dependency
Browse files Browse the repository at this point in the history
Remove HG_Core_event_ready_loopback() from public API
  • Loading branch information
soumagne committed Aug 12, 2024
1 parent c4a7cc0 commit fd4e665
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
48 changes: 38 additions & 10 deletions src/mercury_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,12 @@ hg_core_completion_count(const struct hg_core_private_context *context);
static void
hg_core_completion_trigger(struct hg_completion_entry *hg_completion_entry);

/**
* Check for events on loopback and if it is safe to wait.
*/
static HG_INLINE bool
hg_core_event_ready_loopback(struct hg_core_private_context *context);

/**
* Make progress.
*/
Expand Down Expand Up @@ -5237,6 +5243,22 @@ hg_core_completion_trigger(struct hg_completion_entry *hg_completion_entry)
}
}

/*---------------------------------------------------------------------------*/
static HG_INLINE bool
hg_core_event_ready_loopback(struct hg_core_private_context *context)
{
if (context->loopback_notify.event > 0) {
/* We will need to notify the event if we're waiting */
hg_atomic_cas32(&context->loopback_notify.must_notify, 0, 1);
if (hg_core_completion_count(context) > 0) {
hg_atomic_cas32(&context->loopback_notify.must_notify, 1, 0);
return true;
}
}

return false;
}

/*---------------------------------------------------------------------------*/
static hg_return_t
hg_core_progress_wait(
Expand Down Expand Up @@ -7022,21 +7044,27 @@ HG_Core_event_get_wait_fd(const hg_core_context_t *context)

/*---------------------------------------------------------------------------*/
bool
HG_Core_event_ready_loopback(hg_core_context_t *context)
HG_Core_event_ready(hg_core_context_t *context)
{
struct hg_core_private_context *private_context =
(struct hg_core_private_context *) context;

if (private_context->loopback_notify.event > 0) {
/* We will need to notify the event if we're waiting */
hg_atomic_cas32(&private_context->loopback_notify.must_notify, 0, 1);
if (hg_core_completion_count(private_context) > 0) {
hg_atomic_cas32(
&private_context->loopback_notify.must_notify, 1, 0);
return true;
}
}
HG_CHECK_SUBSYS_ERROR_NORET(
poll, context == NULL, error, "NULL HG core context");

if (hg_core_completion_count(private_context) > 0)
return true;
#ifdef NA_HAS_SM
if ((context->core_class->na_sm_class != NULL) &&
!NA_Poll_try_wait(
context->core_class->na_sm_class, context->na_sm_context))
return true;
#endif
if (!NA_Poll_try_wait(context->core_class->na_class, context->na_context))
return true;
return hg_core_event_ready_loopback(private_context);

error:
return false;
}

Expand Down
30 changes: 1 addition & 29 deletions src/mercury_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1010,19 +1010,8 @@ HG_Core_event_get_wait_fd(
*
* \return true if there is already work to be progressed or false otherwise
*/
static HG_INLINE bool
HG_Core_event_ready(hg_core_context_t *context) HG_WARN_UNUSED_RESULT;

/**
* Used to signal when it is safe to block on the file descriptor of the
* context's wait object or if there is already work that can be progressed.
*
* \param context [IN/OUT] pointer to HG core context
*
* \return true if there is already work to be progressed or false otherwise
*/
HG_PUBLIC bool
HG_Core_event_ready_loopback(hg_core_context_t *context) HG_WARN_UNUSED_RESULT;
HG_Core_event_ready(hg_core_context_t *context) HG_WARN_UNUSED_RESULT;

/**
* Progress communication by placing any completed RPC events into the
Expand Down Expand Up @@ -1332,23 +1321,6 @@ HG_Core_get_output(
return HG_SUCCESS;
}

/*---------------------------------------------------------------------------*/
static HG_INLINE bool
HG_Core_event_ready(hg_core_context_t *context)
{
if (HG_Core_context_get_completion_count(context) > 0)
return true;
#ifdef NA_HAS_SM
if ((context->core_class->na_sm_class != NULL) &&
!NA_Poll_try_wait(
context->core_class->na_sm_class, context->na_sm_context))
return true;
#endif
if (!NA_Poll_try_wait(context->core_class->na_class, context->na_context))
return true;
return HG_Core_event_ready_loopback(context);
}

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit fd4e665

Please sign in to comment.