Esempio n. 1
0
int qthread_multinode_register(uint32_t  uid,
                               qthread_f f)
{
    int ret = 0;

    if (0 == initialized) { return 1; }

    qthread_debug(MULTINODE_CALLS, "[%d] begin qthread_multinode_register(uid=%d, ptr=0x%lx)\n",
                  my_rank, uid, (unsigned long)f);

    // Check that UID is strictly positive
    if (0 == uid) {
        fprintf(stderr, "invalid action id %d: must be > 0", uid);
        return 1;
    }

    // Check that UID is not used more than once
    if (NULL != qt_hash_get(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid)) {
        fprintf(stderr, "duplicate registration of action uid %d\n", uid);
        return 1;
    }

    ret = qt_hash_put(uid_to_ptr_hash, (qt_key_t)(uintptr_t)uid, f);
    if (ret != 1) {
        qthread_debug(MULTINODE_DETAILS, "[%d] uid -> ptr registration failed\n",
                      my_rank);
        return 1;
    }

    // Check that function pointer is not used more than once
    if (NULL != qt_hash_get(ptr_to_uid_hash, f)) {
        fprintf(stderr, "duplicate registration of action function 0x%lx\n",
                (unsigned long)f);
        return 1;
    }

    ret = qt_hash_put(ptr_to_uid_hash, f, (void *)(uintptr_t)uid);
    if (ret != 1) {
        qthread_debug(MULTINODE_DETAILS, "[%d] ptr -> uid registration failed\n",
                      my_rank);
        return 1;
    }

    qthread_debug(MULTINODE_CALLS, "[%d] end qthread_multinode_register\n",
                  my_rank);

    return 0;
}
Esempio n. 2
0
void *qt_dictionary_put_if_absent(qt_dictionary *dict,
                                  void          *key,
                                  void          *value)
{
    return qt_hash_put(dict, key, value, PUT_IF_ABSENT);
}
Esempio n. 3
0
void *qt_dictionary_put(qt_dictionary *dict,
                        void          *key,
                        void          *value)
{
    return qt_hash_put(dict, key, value, PUT_ALWAYS);
}