windows - Using Win32 API functionality along with/from pthreads -


i have own threading library built using tinythread++. works quite well, , great learning experience me. have own datastructures passing around messages, , interface makes sense me, because author.

whenever thread created in system, runs in loop, , checks messages via message passing protocol of own devising.

now want start using windows api functionality, , windows has own set of conventions , message queues, etc. i'm pretty sure tinythread++ uses pthreads. since i'm using mingw, i'm wondering if pthreads being implemented on windows threads. if case, may able treat pthreads-threads windows-threads. if not, suspect might run strange behavior.

edit: looking @ thread type given tinythread++ looks uses windows handle keep track of threads , uses _beginthreadex spawn them.

my question is, windows happy if go around calling setwindowshookex point in pthreads code? realize need have windows message polling loop in same thread. intend this:

try {      hhook mousehook = setwindowshookex(wh_mouse_ll, mousehookproc,         null, 0);     if (mousehook == null) printf("mousehook error %u\n",getlasterror());      while(true) {         msg msg;         if (getmessage(&msg,0,0,0)) {             translatemessage(&msg);             dispatchmessage(&msg);         }     }     unhookwindowshookex(mousehook);      printf("procedure completed without exceptional events.\n");  } catch (...) {     printf("exception!\n"); } 

that should fine.

you may run trouble if try pass pthread thread ids windows threading functions want thread handle, here need loop stay in same thread setwindowshookex.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -