summaryrefslogtreecommitdiff
path: root/grc/python
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2015-01-07 23:07:04 +0100
committerSebastian Koslowski <koslowski@kit.edu>2015-04-02 09:20:25 +0200
commit95c59385950ca3012ba1b608250454271fb80707 (patch)
treeab72e7820e043c47bf719b35d3a63f3a8fa1ddcc /grc/python
parentc201a582ea5a9e3f3c541b88f10079906705a0ca (diff)
grc: optional thread-safe setters in generated code (#748)
Diffstat (limited to 'grc/python')
-rw-r--r--grc/python/flow_graph.tmpl19
1 files changed, 17 insertions, 2 deletions
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index 45d5d608b9..814b513213 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -31,6 +31,9 @@ $DIVIDER
#end if
# Generated: $time.ctime()
$DIVIDER
+#if $flow_graph.get_option('thread_safe_setters')
+import threading
+#end if
## Call XInitThreads as the _very_ first thing.
## After some Qt import, it's too late
@@ -141,6 +144,10 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
self.message_port_register_hier_in("$pad['label']")
#end for
#end if
+#if $flow_graph.get_option('thread_safe_setters')
+
+ self._lock = threading.RLock()
+#end if
########################################################
##Create Parameters
## Set the parameter to a property of self.
@@ -264,10 +271,18 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
return self.$id
def set_$(id)(self, $id):
+ #if $flow_graph.get_option('thread_safe_setters')
+ with self._lock:
+ self.$id = $id
+ #for $callback in $var_id2cbs[$id]
+ $indent($callback)
+ #end for
+ #else
self.$id = $id
- #for $callback in $var_id2cbs[$id]
+ #for $callback in $var_id2cbs[$id]
$indent($callback)
- #end for
+ #end for
+ #end if
#end for
########################################################