Changeset 46eec3b in mainline for uspace/lib/c/generic/async.c


Ignore:
Timestamp:
2011-01-25T22:15:36Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8526e585
Parents:
c80fdd0
Message:

Introduce a callback mechanism to create and destroy client data area.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    rc80fdd0 r46eec3b  
    168168/** Identifier of the incoming connection handled by the current fibril. */
    169169fibril_local connection_t *FIBRIL_connection;
     170
     171static void *default_client_data_constructor(void)
     172{
     173        return NULL;
     174}
     175
     176static void default_client_data_destructor(void *data)
     177{
     178}
     179
     180static async_client_data_ctor_t async_client_data_create =
     181    default_client_data_constructor;
     182static async_client_data_dtor_t async_client_data_destroy =
     183    default_client_data_destructor;
     184
     185void async_set_client_data_constructor(async_client_data_ctor_t ctor)
     186{
     187        async_client_data_create = ctor;
     188}
     189
     190void async_set_client_data_destructor(async_client_data_dtor_t dtor)
     191{
     192        async_client_data_destroy = dtor;
     193}
    170194
    171195static void default_client_connection(ipc_callid_t callid, ipc_call_t *call);
     
    517541        client_t *cl;
    518542        link_t *lnk;
     543        void *unref_client_data = NULL;
    519544
    520545        /*
     
    542567                }
    543568                cl->in_task_hash = FIBRIL_connection->in_task_hash;
    544                 cl->data = NULL;
     569                async_serialize_start();
     570                cl->data = async_client_data_create();
     571                async_serialize_end();
    545572                cl->refcnt = 1;
    546573                hash_table_insert(&client_hash_table, &key, &cl->link);
     
    560587        if (--cl->refcnt == 0) {
    561588                hash_table_remove(&client_hash_table, &key, 1);
     589                unref_client_data = cl->data;
    562590                free(cl);
    563591        }
    564592        futex_up(&async_futex);
     593
     594        if (unref_client_data)
     595                async_client_data_destroy(unref_client_data);
    565596
    566597        /*
Note: See TracChangeset for help on using the changeset viewer.