Browse Source

More Thread docs;

bjorn 7 years ago
parent
commit
4c59de7ece

+ 17 - 0
api/lovr/thread/Thread/getError.lua

@@ -0,0 +1,17 @@
+return {
+  summary = 'Get the Thread\s error message.',
+  description = [[
+    Returns the message for the error that occurred on the Thread, or nil if no error has occurred.
+  ]],
+  arguments = {},
+  returns = {
+    {
+      name = 'error',
+      type = 'string',
+      description = 'The error message, or nil if no error has occurred on the Thread.'
+    }
+  },
+  related = {
+    'lovr.threaderror'
+  }
+}

+ 14 - 0
api/lovr/thread/Thread/init.lua

@@ -0,0 +1,14 @@
+return {
+  summary = 'A separate thread of execution that can run code in parallel with other threads.',
+  description = [[
+    A Thread is an object that runs a chunk of Lua code in the background.  Threads are completely
+    isolated from other threads, meaning they have their own Lua context and can't access the
+    variables and functions of other threads.  Communication between threads is limited and is
+    accomplished by using `Channel` objects.
+  ]],
+  constructor = { 'lovr.thread.newThread' },
+  related = {
+    'lovr.threaderror',
+    'Channel'
+  }
+}

+ 15 - 0
api/lovr/thread/Thread/isRunning.lua

@@ -0,0 +1,15 @@
+return {
+  summary = 'Check if the Thread is running.',
+  description = 'Returns whether or not the Thread is currently running.',
+  arguments = {},
+  returns = {
+    {
+      name = 'running',
+      type = 'boolean',
+      description = 'Whether or not the Thread is running.'
+    }
+  },
+  related = {
+    'Thread:start'
+  }
+}

+ 6 - 0
api/lovr/thread/Thread/start.lua

@@ -0,0 +1,6 @@
+return {
+  summary = 'Start the Thread.',
+  description = 'Starts the Thread.',
+  arguments = {},
+  returns = {}
+}

+ 9 - 0
api/lovr/thread/Thread/wait.lua

@@ -0,0 +1,9 @@
+return {
+  summary = 'Wait for the Thread to complete.',
+  description = 'Waits for the Thread to complete, then returns.',
+  arguments = {},
+  returns = {},
+  related = {
+    'Thread:isRunning'
+  }
+}

+ 4 - 0
api/lovr/thread/newThread.lua

@@ -16,4 +16,8 @@ return {
     }
   },
   notes = 'The Thread won\'t start running immediately.  Use `Thread:start` to start it.',
+  related = {
+    'Thread:start',
+    'lovr.threaderror'
+  }
 }