Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Async Event Threads

Name: Anonymous 2011-11-24 18:53

Is it possible to fork a thread from and asynchronous event loop and have it renable the originating event. Essentially pushing a cpu bound operation into something which has its share of the cpu and passes data back?

Name: Anonymous 2011-11-24 18:57

yes

Name: sage 2011-11-24 19:02

no

Name: Anonymous 2011-11-24 19:05

maybe ?

Name: Anonymous 2011-11-24 20:24

so

Name: Anonymous 2011-11-25 6:23

Japan

Name: Anonymous 2011-11-25 13:25

well...?

Name: Anonymous 2011-11-25 22:20

>>7

some like this could do:



typedef union {
  HaxAniiEvent hax,
  FindAniiEvent find
} Event;

Event event;
while(getNextEvent(&event)) {
  switch(event.type) {
    case HAX_ANII:
      spawn_thread(haxAniiWorkerFunction, event.hax.targetAniiList);
      break;
    case FIND_ANII:
      spawn_thread(anusSearchingFunction, event.find.aniiSearchArea);
      break;
    default:
      assert(0);
  }
}

Name: Anonymous 2011-11-25 22:21

typo:

>>8


typedef union {
  int type;
  HaxAniiEvent hax,
  FindAniiEvent find
} Event;


sorry.

Name: Anonymous 2011-11-26 4:32

>>9
That wouldn't work, you can't have both Event.type and (Event.hax or Event.find) at once.
You have to wrap the Event in a struct or have the type external.

Name: Anonymous 2011-11-26 4:39

>>10

yeah, the HaxAniiEvent and FindAniiEvent structures would need to have an int type for their very first field, and it would need to be set to HAX_ANII or FIND_ANII depending on what getNextEvent decided to fill into the Event union. I was borrowing from how htey do events in X windows.

Don't change these.
Name: Email:
Entire Thread Thread List