src/axl_async_bbapi.c
/* Returns a unique BBTAG into *tag.  The tag returned must be unique
 * such that no two callers on the node will ever get the same tag
 * within a job.
 *
 * Returns 0 on success, 1 otherwise. */
Returns a unique BBTAG into *tag.  The tag returned must be unique
such that no two callers on the node will ever get the same tag
within a job.

Returns 0 on success, 1 otherwise.
Returns a unique BBTAG into * tag . The tag returned must be unique such that no two callers on the node will ever get the same tag within a job . Returns 0 on success 1 otherwise .
static BBTAG axl_get_unique_tag(void)
{
    pid_t tid = syscall(__NR_gettid);
    uint64_t timestamp = time(NULL);
    struct timespec now;
    clock_gettime(CLOCK_MONOTONIC, &now);
    uint64_t nsecs = now.tv_nsec;
    usleep(250000);
    uint64_t tag = ((timestamp << 32) | ((uint32_t) tid & 0x3FFFFFFF) | (nsecs / 250000000));
    return tag;
}
static BBTAG axl_get_unique_tag ( void ) { pid_t tid = syscall ( __NR_gettid ) ; uint64_t timestamp = time ( NULL ) ; struct timespec now ; clock_gettime ( CLOCK_MONOTONIC , & now ) ; uint64_t nsecs = now . tv_nsec ; usleep ( 250000 ) ; uint64_t tag = ( ( timestamp << 32 ) | ( ( uint32_t ) tid & 0x3FFFFFFF ) | ( nsecs / 250000000 ) ) ; return tag ; }
Returns a unique BBTAG into *tag.
Returns a unique BBTAG into * tag .
/* This is somewhat of a hack.
     *
     * We need a 64-bit tag that will never be repeated on this node.  To do
     * that we construct an ID of:
     *
     * 32-bit unix timestamp +
     * 30-bit thread ID (30 bits according to https://github.com/torvalds/linux/blob/master/include/linux/threads.h#L31) +
     * 2-bit quarter second
     *
     * We also wait for a quarter second to elapse so we know the next caller
     * will not fall on the same quarter second and get the same tag. */ /* Get thread ID.  This is non-portable, Linux only. */ /* seconds since epoch */ /* get nanoseconds */ /* wait quarter second */