diff options
author | Kaiyu Yang <yangky11@outlook.com> | 2015-10-04 08:47:51 +0300 |
---|---|---|
committer | Kaiyu Yang <yangky11@outlook.com> | 2015-10-04 08:47:51 +0300 |
commit | ac3fad42964bcae3b07950192c0d3ecbfcf9c2ba (patch) | |
tree | d739fe37127fc3b05c80a7fddf6e1aea3038efcf /README.md | |
parent | 267759ad5899ddd3f5799f378880a7f67163efaa (diff) |
format
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -206,9 +206,9 @@ threads.Threads(4, ``` Note that the id of each thread is also stored into the global variable `__threadid` (in each thread Lua state). -Special notice about upvalues: -When deserializing a callback, upvalues in that callback must be of known types. Since f1,f2,... in [threads.Threads](#threads.Threads) are deserialized in order, -we suggest that you make a separated f1 containing all the definitions and put the other code in f2,f3,... +Notice about Upvalues: +When deserializing a callback, upvalues must be of known types. +Since f1,f2,... in [threads.Threads](#threads.Threads) are deserialized in order, we suggest that you make a separated f1 containing all the definitions and put the other code in f2,f3,... e.g. ``` require 'nn' @@ -216,9 +216,9 @@ local threads = require 'threads' local model = nn.Linear(5, 10) threads.Threads( 2, - function(idx) - require 'nn' - local myModel = model:clone() -- This code will crash, because the upvalue 'model' is of unknown type before deserialization + function(idx) -- This code will crash + require 'nn' -- because the upvalue 'model' + local myModel = model:clone() -- is of unknown type before deserialization end ) ``` @@ -229,11 +229,11 @@ local threads = require 'threads' local model = nn.Linear(5, 10) threads.Threads( 2, - function(idx) + function(idx) -- This code is OK. require 'nn' - end, + end, -- child threads know nn.Linear when deserializing f2 function(idx) - local myModel = model:clone() -- This code is OK. child threads know nn.Linear when deserializing f2 because f1 has already been executed + local myModel = model:clone() -- because f1 has already been executed end ) ``` |