lib/sync_attr.rb in sync_attr-1.0.0 vs lib/sync_attr.rb in sync_attr-2.0.0

- old
+ new

@@ -1,35 +1,9 @@ -# Synchronize access and lazy initialize one or more variables in a class -# -# Load configuration files and thread connection pools on demand rather than -# at start time or via a Rails initializer -# -# Locking: Shared reads and exclusive writes -# sync_attr ensures that all reads are shared, meaning that all -# reads to attributes can occur at the same time. All writes are exclusive, so -# all reads and other writes will be blocked whilst a write takes place. -# -# Example: -# class MyClass -# include SyncAttr -# -# # Create class variable @@http and initialize on the first access -# # protecting access by concurrent threads using a Semaphore -# sync_cattr_reader :http do -# PersistentHTTP.new() -# end -# -# Author: Reid Morrison <reidmo@gmail.com> -require 'sync' +require 'thread' require 'sync_attr/version' require 'sync_attr/class_attributes' -require 'sync_attr/instance_attributes' +require 'sync_attr/attributes' +# include SyncAttr is deprecated. Not required for class instance attributes. +# include SyncAttr::Attributes for object instance attributes. module SyncAttr - # Add class methods and initialize mixin - def self.included(base) - base.extend(SyncAttr::ClassAttributes::ClassMethods) - base.extend(SyncAttr::InstanceAttributes::ClassMethods) - base.send(:sync_cattr_init) - base.send(:sync_attr_init) - end end