home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / baku100.zip / baku100 / Kernel / Process.tonyu < prev    next >
Text File  |  2002-10-26  |  1KB  |  69 lines

  1. extends classes.lang.Object;
  2.  
  3. destructor free(){
  4.   parent=0;
  5.   native_free(p); 
  6. }
  7. native native_free;
  8.  
  9. constructor Process(o,f,a) {
  10.  p=native_init(o,f);
  11.  aobj=o;
  12.  o._pProc=this;
  13.  autoKill=a;
  14.  parent=$currentProcess;
  15. }
  16. native native_init;
  17.  
  18. function exec() {
  19. //  if (parent && parent.halted()) {
  20. //    kill();
  21. //  } else {
  22.     $currentProcess=this;
  23.     native_exec(p);
  24. //  }
  25. }
  26. native native_exec;
  27.  
  28. function suspend() {
  29.   native_suspend(p);
  30. }
  31. native native_suspend;
  32.  
  33. function halted() {
  34.   return native_halted(p);
  35. }
  36. native native_halted;
  37.  
  38. function gc_mark() {
  39.   native_proc_mark(p);
  40. }
  41. native native_proc_mark;
  42.  
  43. function kill() {
  44.   aobj._pProc=0;
  45.   aobj=0;
  46.   native_kill(p);
  47. }
  48. native native_kill;
  49.  
  50. // nextWait 0: active
  51. //          1: eternal
  52. //       other: wake at nextWait
  53. function wait(t) {
  54.   if (nextWake) return;
  55.   if (!t) nextWake=1;
  56.   else {
  57.     nextWake=$curProcGroup.frameCount+trunc(t);
  58.     $waitProcs.add(this);
  59.   }
  60.   deletedFromProcs=0;
  61.   suspend();
  62. }
  63.  
  64. function notify() {
  65.   if (!nextWake || !aobj) return;
  66.   if (deletedFromProcs) $procs.add(this);
  67.   nextWake=0;
  68. }
  69.