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:39:37 +0300
committerKaiyu Yang <yangky11@outlook.com>2015-10-04 08:39:37 +0300
commitb3d8fb70bf573c5d4c3818e9b6b7c573a03829d5 (patch)
tree44dfbea281a153ce84393dc99e859b43d1e9d77b
parent7c5ff00fa98825cd477eb767fb7dc0832592f61c (diff)
first commit
-rw-r--r--README.md32
1 files changed, 32 insertions, 0 deletions
diff --git a/README.md b/README.md
index 263bc99..fb13838 100644
--- a/README.md
+++ b/README.md
@@ -206,6 +206,38 @@ 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 a child deserialize a callback, all the upvalues in it must be of known types. Since the callbacks in 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,...
+For example
+```
+require 'nn'
+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
+ end
+)
+```
+
+```
+require 'nn'
+local threads = require 'threads'
+local model = nn.Linear(5, 10)
+threads.Threads(
+ 2,
+ function(idx)
+ require 'nn'
+ end,
+ function(idx)
+ local myModel = model:clone() -- This code is OK. child threads know nn.Linear when deserializing f2 because f1 has already been executed
+ end
+)
+```
+
<a name='threads.specific'/>
#### Threads:specific(boolean) ####