Thread: Is it possible to set/get user data to HANDLE/pthread_t?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,735
    Quote Originally Posted by hamster_nz View Post
    I just want to show you why people here aren't able to offer you much useful advice. It might just be my failings.

    I've gone through the last code snipped, and replaced everything that has no meaning to me with XXXXs, even after a few attempts to Google things (e.g. pawsu2pawju - Google Search )

    Code:
    void* pawRUN_initCB( void *ud )
    {
        XXXXXX Run = ud;
        XXXXXXX = Run;
        Run->tid = XXXXXXXXXXXX();
        if ( Run->initCB )
        {
            XXXXX *key = &(Run->env_key), *val = &(Run->env_val);
            XXXXXXXXXXX( key, Run->tid, XXXXXXXXXX );
            XXXXXXXXXXX( val, (XXXXX)Run, XXXXXXXXXXXX );
            XXXXXXX( key->txt, key->len, XXXXXXXXXX, sizeof(XXXXXXXXXX) - 1 );
            setenv( key->txt, val->txt, 1 );
            XXXXXXXXXXXXX( Run->id, Run );
            XXXXXXXXXXXXXXX( Run->id, XXXXXXXXXXXXX );
            Run->initCB( Run->id, Run->ud );
            unsetenv( key->txt );
        }
        return NULL;
    }
    
    
    static pthread_t pawrun_pthread( XXXXXX run )
    {
        XXXX txt = NULL;
        XXXXX key = XXXXXXXX, val = BAD_XXXXXXXX;
        XXXXX addr = 0;
        XXXXXX Run = NULL;
        XXXXXXXX( &key, run, XXXXXXXXXXX );
        XXXXXXX( key.txt, key.len, XXXXXXXXXX, sizeof(XXXXXXXXXX)-1 );
        txt = getenv( key.txt );
        XXXXXXX( val.txt, txt, XXXXXXXX(txt) );
        XXXXXXXXXXX( &addr, &val, XXXXXXXXXXXX );
        Run = (void*)addr;
        return Run->thread;
    }
    There really isn't much left that has any context for me, I'm sure others here feel the same way.

    I'm not asking for an explanation of what "pawsu2pawju()" does, or even what a "pawsu" or "pawju" is, I just want to make you aware that what you ask relies heavily on stuff nobody here knows, so you won't get meaningful answers.
    well the paw* calls I'm not expecting anyone to have an exact understanding of, just a rough idea from the code, basically just turning the thread id & the pointer into text that can be added to the environment variables to then be read later when needed, the prefix inserted is just for distinguishing the number from other variables that happen to use the same number (assuming it is the case is better than assuming it is not the case)

    Edit: Btw pawrun just maps to either HANDLE or thread id:
    Code:
    #ifdef PAW_ON_WINDOWS
    typedef void* pawrun;
    #define BAD_pawrun NULL
    #else
    typedef pawjd pawrun;
    #define BAD_pawrun -1
    #endif
    Wanted a reasonably short name for it and even if the typedef is not enough the typedef following it gives enough meaning about it's rough purpose:
    Code:
    typedef void* (*pawrun_cb)( pawd id, void *ud );
    typedef struct _PAW_THREAD PAW_THREAD, *pawRUN;
    typedef const PAW_THREAD *PAWRUN;
    I'll probably do a mass replace later to paw_thread but for now to help my fingers I'm using shorthands

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Data types and user input
    By john.joseph.law in forum C++ Programming
    Replies: 3
    Last Post: 09-19-2012, 03:14 AM
  2. Which is a better practice? (Global handle or finding handle)
    By C_Sparky in forum Windows Programming
    Replies: 4
    Last Post: 12-31-2010, 07:32 PM
  3. How to handle inputs if the user inputs the wrong thing
    By bassist11 in forum C Programming
    Replies: 5
    Last Post: 09-22-2010, 04:28 AM
  4. protect data from user
    By rogster001 in forum C Programming
    Replies: 8
    Last Post: 08-27-2010, 06:23 PM
  5. prompting user for data
    By radical in forum C Programming
    Replies: 5
    Last Post: 07-28-2005, 11:45 AM

Tags for this Thread