1. 04 May, 2021 3 commits
  2. 03 May, 2021 2 commits
  3. 01 May, 2021 2 commits
    • chaz's avatar
      Move functions out of common.c, remove it · eff7d208
      chaz authored
      There wasn't much there -- resumable was only used by watchers, so that
      moved there, and the alloc functions went into cho.c.  Just cleans
      things up a bit.
      eff7d208
    • chaz's avatar
      Add start method on context · 32dd939b
      chaz authored
      start allows you to add tasks to the currently executing cho.run call's
      set of tasks.  It works similarly to cho.run, but leverages the event
      loop created on a different thread (from start's perspective) to allow
      you to run tasks in the background (of the current thread).
      32dd939b
  4. 29 Apr, 2021 7 commits
    • chaz's avatar
      Clean up the index functions a bit · b8f65ec9
      chaz authored
      b8f65ec9
    • chaz's avatar
      Be consistent with every lua function named cholua_* · 184ef7bb
      chaz authored
      I like the hint right there in the name that it's not meant to be called
      from C, but from lua.
      184ef7bb
    • chaz's avatar
      Add some basic time tests · bce6c62f
      chaz authored
      bce6c62f
    • chaz's avatar
      Use a more concise lua arg check · c7113b10
      chaz authored
      I didn't know this function existed till a few changes ago.  Cool.
      c7113b10
    • chaz's avatar
      Refine a TODO idea · be0a1c41
      chaz authored
      I like the name scheduler better, since the idea is it creates an object
      that waits on a schedule.
      be0a1c41
    • chaz's avatar
      Use real words for variables · 52a72dfe
      chaz authored
      52a72dfe
    • chaz's avatar
      Rework module to include itself as an upvalue · 6c85f9c8
      chaz authored
      This reworks the module so that it can always refer to its own table
      through an upvalue.  This makes it so we don't need to store things in a
      global, but can still call closures etc. that we define on ourselves
      from C in a consistent way.
      
      It unfortunately means that the C api gets more complicated, since it's
      always going to need some kind of pointer/reference to the module table
      to do anything useful.  Whereas before we could just expose the C
      functions that created the module table functions and be done, those are
      now useless without the closure/upvalue that wraps the calls.
      6c85f9c8
  5. 28 Apr, 2021 5 commits
    • chaz's avatar
      Give cho.VERSION the public api treatment · 234aa14d
      chaz authored
      This adds docs for the VERSION string and implements it in the context
      as well as the module, same as other api features.
      234aa14d
    • chaz's avatar
      Add a thread id argument to cho.run functions · 6adf5a84
      chaz authored
      This adds a "unique" (until it wraps) counter thread id as an upvalue to
      the run function, increments it each thread it creates, and passes its
      value on as an argument to the functions passed to run.
      6adf5a84
    • chaz's avatar
      Nix pointless define for something used once · 297d40b8
      chaz authored
      297d40b8
    • chaz's avatar
      Documentation tweaks · 7dd5a347
      chaz authored
      7dd5a347
    • chaz's avatar
      Propagate errors in cho.run, don't return them · b1230fb0
      chaz authored
      This removes the "protected mode" from cho.run calls.  Now, any errors
      encountered running a function passed to cho.run are simply propagated
      to the cho.run caller.  This makes more sense than having cho.run act
      like pcall, catching and returning errors.
      
      This also improves consistency around *when* errors happen in the
      threads relative to when they may have been yielded/resumed.  Previously
      I had simply re-thrown errors that happened after a resume, because at
      that point in the C code you're outside of the cho.run handler, so
      returning it would require extra work.  Now, errors just get re-thrown
      either way.
      b1230fb0
  6. 26 Apr, 2021 5 commits
    • chaz's avatar
      Add/reformulate some TODOs · 8329229e
      chaz authored
      8329229e
    • chaz's avatar
      Check delay > 0, make docs more precise about args · cd3df929
      chaz authored
      This makes sure the delay given to cho:delay() is positive (negative
      makes no sense, and for 0 just use cho:yield()).  While I'm here, I
      updated some language in the docs around args to be more precise.
      cd3df929
    • chaz's avatar
      Simpler arg checks in a few places · e0a1dc5b
      chaz authored
      This gets us more consistently throwing errors for bad arguments,
      instead of a few places where we would throw for invalid typed args but
      then return a failure message if it couldn't be parsed, for example.
      This way we just always throw.
      
      The error messages got slightly less useful (they don't tell you what
      value you passed) but meh.
      e0a1dc5b
    • chaz's avatar
      Add see-alsos to open and wrap_fd in the docs · 7e9e6fa8
      chaz authored
      7e9e6fa8
    • chaz's avatar
      Rename cho:open_fd -> cho:wrap_fd · 01c36904
      chaz authored
      Nothing is being opened, but an open fd is being wrapped in a file
      object.  This name is more precise.
      01c36904
  7. 25 Apr, 2021 7 commits
  8. 24 Apr, 2021 4 commits
  9. 23 Apr, 2021 5 commits
    • chaz's avatar
      Add file:open_fd method · 7141f6fa
      chaz authored
      Now we need a flag to tell the file not to automatically close its fd
      when it gets GC'd.  Youc an still call f:close() on it if you want to
      close the fd yourself, but since you opened it through some other means,
      I think it's fair to make you do it explicitly.
      
      Also cleans up some formatting in other tests.
      7141f6fa
    • chaz's avatar
      Allow optional args to be passed as nil · dd49aba9
      chaz authored
      dd49aba9
    • chaz's avatar
      Add cho.time, a more accurate timer · ca8f306f
      chaz authored
      Lua's built-in time functions are a bit lacking.  This gives us a
      subsecond-accuracy epoch time accessor, which I then use in the delay
      tests to check how long they take.
      
      I also added another test for bad arguments in the delay function.
      ca8f306f
    • chaz's avatar
      Add single shot delay · 2a264793
      chaz authored
      I need a higher precision way to check how long things actually took.
      2a264793
    • chaz's avatar
      Rename cho.assert -> cho.check · 44896d23
      chaz authored
      It wasn't really an assertion, but checking for a returned error.
      44896d23