Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp> --- ryu/lib/synchronized.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 ryu/lib/synchronized.py
diff --git a/ryu/lib/synchronized.py b/ryu/lib/synchronized.py new file mode 100644 index 0000000..d1129db --- /dev/null +++ b/ryu/lib/synchronized.py @@ -0,0 +1,29 @@ +# Copyright (C) 2012 Nippon Telegraph and Telephone Corporation. +# Copyright (C) 2012 Isaku Yamahata <yamahata at private email ne jp> +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import functools + + +def synchronized(lockname): + def _synchronized(meth): + @functools.wraps(meth) + def wrapped(self, *args, **kwargs): + lock = getattr(self, lockname) + with lock: + meth(self, *args, **kwargs) + return wrapped + + return _synchronized -- 1.7.10.4 ------------------------------------------------------------------------------ Keep yourself connected to Go Parallel: TUNE You got it built. Now make it sing. Tune shows you how. http://goparallel.sourceforge.net _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel