Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/threads-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaiyu Yang <yangky11@outlook.com>2015-10-04 08:47:51 +0300
committerKaiyu Yang <yangky11@outlook.com>2015-10-04 08:47:51 +0300
commitac3fad42964bcae3b07950192c0d3ecbfcf9c2ba (patch)
treed739fe37127fc3b05c80a7fddf6e1aea3038efcf
parent267759ad5899ddd3f5799f378880a7f67163efaa (diff)
format
-rw-r--r--README.md18
1 files changed, 9 insertions, 9 deletions
diff --git a/README.md b/README.md
index 015c2f9..7d3e6a9 100644
--- a/README.md
+++ b/README.md
@@ -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
)
```