Exemplo n.º 1
0
/*
doc:	<routine name="rt_processor_subscribe_wait_condition" return_type="int" export="shared">
doc:		<summary> Register for a notification when the memory region handled by processor 'self' may have changed.
doc:			This is used to implement wait condition change signalling.
doc:			The registration is only valid for a single notification and will be deleted by 'self' afterwards.
doc:			Note: This feature is executed by the 'client' processor (i.e. thread), and can only be called when the
doc:			supplier 'self' is synchronized with the client. </summary>
doc:		<param name="self" type="struct rt_processor*"> The processor that will send the notification in the future. Must not be NULL. </param>
doc:		<param name="client" type="struct rt_processor*"> The processor interested in wait condition changes. Must not be NULL. </param>
doc:		<return> T_OK on success. T_NO_MORE_MEMORY in case of a memory allocation failure. </return>
doc:		<thread_safety> Not safe. </thread_safety>
doc:		<synchronization> Only call when 'self' is synchronized with 'client'. </synchronization>
doc:	</routine>
*/
rt_shared int rt_processor_subscribe_wait_condition (struct rt_processor* self, struct rt_processor* client)
{
#ifdef EIF_ASSERTIONS
	struct rt_private_queue* pq = NULL; /* For assertion checking. */
#endif
	REQUIRE ("self_not_null", self);
	REQUIRE ("client_not_null", client);
	REQUIRE ("queue_available", T_OK == rt_queue_cache_retrieve (&client->cache, self, &pq));
	REQUIRE ("synchronized", rt_private_queue_is_synchronized (pq));

	return subscriber_list_t_extend (&self->wait_condition_subscribers, client);
}
Exemplo n.º 2
0
/*
doc:	<routine name="rt_request_group_add" return_type="int" export="shared">
doc:		<summary> Add a new supplier to the request group. This feature cannot be called any more after the first lock operation. </summary>
doc:		<param name="self" type="struct rt_request_group*"> The request group struct. Must not be NULL. </param>
doc:		<param name="a_client" type="struct rt_processor*"> The supplier processor to be added to this request group. Must not be NULL. </param>
doc:		<return> T_OK on success. T_NO_MORE_MEMORY in case of a memory allocation failure. </return>
doc:		<thread_safety> Not safe. </thread_safety>
doc:		<synchronization> None. </synchronization>
doc:	</routine>
*/
rt_shared int rt_request_group_add (struct rt_request_group* self, struct rt_processor* supplier)
{
    struct rt_private_queue* pq = NULL;
    int error = T_OK;

    REQUIRE ("self_not_null", self);
    REQUIRE ("supplier_not_null", supplier);
    REQUIRE ("not_sorted", !self->is_sorted);
    REQUIRE ("not_locked", !self->is_locked);

    error = rt_queue_cache_retrieve (&(self->client->cache), supplier, &pq);
    if (T_OK == error) {
        error = rt_request_group_extend (self, pq);
    }

    return error;
}