Signed-off-by: Isaku Yamahata <[email protected]> --- 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 ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
