osc-ruby 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -0
- data/examples/classic_server.rb +2 -2
- data/examples/event_machine_server.rb +6 -1
- data/lib/osc-ruby.rb +1 -8
- data/lib/osc-ruby/em_server.rb +0 -4
- data/spec/spec_helper.rb +1 -4
- metadata +2 -3
- data/lib/osc-ruby/core_ext/object.rb +0 -37
data/Rakefile
CHANGED
data/examples/classic_server.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# compatible with ruby 1.8
|
2
|
-
|
3
|
-
|
2
|
+
$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib')
|
3
|
+
require 'osc-ruby'
|
4
4
|
|
5
5
|
@server = OSC::Server.new( 3333 )
|
6
6
|
@client = OSC::Client.new( 'localhost', 3333 )
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# compatible with ruby 1.8, 1.9, and jruby
|
2
|
-
|
2
|
+
$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib')
|
3
|
+
require 'osc-ruby'
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'eventmachine'
|
7
|
+
require 'osc-ruby/em_server'
|
3
8
|
|
4
9
|
@server = OSC::EMServer.new( 3333 )
|
5
10
|
@client = OSC::Client.new( 'localhost', 3333 )
|
data/lib/osc-ruby.rb
CHANGED
@@ -1,21 +1,14 @@
|
|
1
|
-
# osc.rb: Written by Tadayoshi Funaba 2005,2006
|
2
|
-
# $Id: osc.rb,v 1.4 2006-11-10 21:54:37+09 tadf Exp $
|
3
|
-
require 'forwardable'
|
4
1
|
require 'socket'
|
5
2
|
require 'thread'
|
6
3
|
|
7
|
-
|
8
|
-
$:.unshift( File.dirname( __FILE__ ) )
|
9
|
-
|
10
4
|
# core extensions
|
11
|
-
require 'osc-ruby/core_ext/object'
|
12
5
|
require 'osc-ruby/core_ext/numeric'
|
13
6
|
require 'osc-ruby/core_ext/time'
|
14
7
|
|
15
|
-
|
16
8
|
# jus the basics
|
17
9
|
require 'osc-ruby/osc_types'
|
18
10
|
require 'osc-ruby/osc_packet'
|
11
|
+
|
19
12
|
require 'osc-ruby/message'
|
20
13
|
require 'osc-ruby/bundle'
|
21
14
|
require 'osc-ruby/address_pattern'
|
data/lib/osc-ruby/em_server.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osc-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aberant
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-01-
|
12
|
+
date: 2010-01-17 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -30,7 +30,6 @@ files:
|
|
30
30
|
- lib/osc-ruby/bundle.rb
|
31
31
|
- lib/osc-ruby/client.rb
|
32
32
|
- lib/osc-ruby/core_ext/numeric.rb
|
33
|
-
- lib/osc-ruby/core_ext/object.rb
|
34
33
|
- lib/osc-ruby/core_ext/time.rb
|
35
34
|
- lib/osc-ruby/em_server.rb
|
36
35
|
- lib/osc-ruby/message.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# lifted from the ruby programming language book, thx matz!
|
2
|
-
|
3
|
-
# Obtain the Mutex associated with the object o, and then evaluate
|
4
|
-
# the block under the protection of that Mutex.
|
5
|
-
# This works like the synchronized keyword of Java.
|
6
|
-
def synchronized(o)
|
7
|
-
o.mutex.synchronize { yield }
|
8
|
-
end
|
9
|
-
# Object.mutex does not actually exist. We've got to define it.
|
10
|
-
# This method returns a unique Mutex for every object, and
|
11
|
-
# always returns the same Mutex for any particular object.
|
12
|
-
# It creates Mutexes lazily, which requires synchronization for
|
13
|
-
# thread safety.
|
14
|
-
class Object
|
15
|
-
# Return the Mutex for this object, creating it if necessary.
|
16
|
-
# The tricky part is making sure that two threads don't call
|
17
|
-
# this at the same time and end up creating two different mutexes.
|
18
|
-
def mutex
|
19
|
-
# If this object already has a mutex, just return it
|
20
|
-
return @__mutex if @__mutex
|
21
|
-
|
22
|
-
# Otherwise, we've got to create a mutex for the object.
|
23
|
-
# To do this safely we've got to synchronize on our class object.
|
24
|
-
synchronized(self.class) {
|
25
|
-
# Check again: by the time we enter this synchronized block,
|
26
|
-
# some other thread might have already created the mutex.
|
27
|
-
@__mutex = @__mutex || Mutex.new
|
28
|
-
}
|
29
|
-
# The return value is @__mutex
|
30
|
-
end
|
31
|
-
end
|
32
|
-
# The Object.mutex method defined above needs to lock the class
|
33
|
-
# if the object doesn't have a Mutex yet. If the class doesn't have
|
34
|
-
# its own Mutex yet, then the class of the class (the Class object)
|
35
|
-
# will be locked. In order to prevent infinite recursion, we must
|
36
|
-
# ensure that the Class object has a mutex.
|
37
|
-
Class.instance_eval { @__mutex = Mutex.new }
|