~ubuntu-branches/ubuntu/vivid/monodevelop/vivid-proposed

« back to all changes in this revision

Viewing changes to external/debugger-libs/Mono.Debugging.Soft/FieldReferenceBatch.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-10-09 14:09:23 UTC
  • mfrom: (10.3.5)
  • Revision ID: package-import@ubuntu.com-20141009140923-s0d22u5f9kg8jvds
Tags: 5.5.0.227-1
* [b2c8331] Imported Upstream version 5.5.0.227 (Closes: #754316)
* [d210995] Delete obsolete patches
* [1b59ae1] Clear patch fizz, via quilt refresh
* [3dd147d] Fix error in configure.in which applies for tarball builds but 
  not git builds when running autoreconf
* [21c2a57] Remove Metacity references for good
* [3331661] Ensure NUnit 2.6.3 is installed
* [fd85c88] Build-depend on NuGet
* [a1ae116] Add WebKit to build dependencies, for Xwt moduleref resolution
* [9b4cf12] Since the GDB addin is integrated now, declare it in 
  debian/control
* [6231562] Correct NUnit links
* [3d2b693] Fix NuGet addin, by copying libs locally
* [74bf9a8] Don't symlink unused Mocks NUnit assembly
* [ade52b2] Ensure IKVM.Reflection is built with default (4.5) profile

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// FieldReferenceBatch.cs
 
3
//  
 
4
// Authors: David Karlaš <david.karlas@xamarin.com>
 
5
// 
 
6
// Copyright (c) 2014 Xamarin Inc. (http://www.xamarin.com)
 
7
// 
 
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
9
// of this software and associated documentation files (the "Software"), to deal
 
10
// in the Software without restriction, including without limitation the rights
 
11
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
12
// copies of the Software, and to permit persons to whom the Software is
 
13
// furnished to do so, subject to the following conditions:
 
14
// 
 
15
// The above copyright notice and this permission notice shall be included in
 
16
// all copies or substantial portions of the Software.
 
17
// 
 
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
23
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
24
// THE SOFTWARE.
 
25
 
 
26
using Mono.Debugger.Soft;
 
27
using System.Collections.Generic;
 
28
 
 
29
namespace Mono.Debugging.Soft
 
30
{
 
31
        public class FieldReferenceBatch
 
32
        {
 
33
                readonly object locker = new object ();
 
34
                readonly object obj;
 
35
                List<FieldInfoMirror> fields = new List<FieldInfoMirror> ();
 
36
                object[] results;
 
37
 
 
38
                public FieldReferenceBatch (object obj)
 
39
                {
 
40
                        this.obj = obj;
 
41
                }
 
42
 
 
43
                public void Add (FieldInfoMirror fieldVal)
 
44
                {
 
45
                        lock (locker) {
 
46
                                fields.Add (fieldVal);
 
47
                        }
 
48
                }
 
49
 
 
50
                public object GetValue (FieldInfoMirror field)
 
51
                {
 
52
                        lock (locker) {
 
53
                                if (results == null || fields.Count != results.Length)
 
54
                                        results = ((ObjectMirror)obj).GetValues (fields);
 
55
                                return results [fields.IndexOf (field)];
 
56
                        }
 
57
                }
 
58
 
 
59
                public void Invalidate ()
 
60
                {
 
61
                        lock (locker) {
 
62
                                results = null;
 
63
                        }
 
64
                }
 
65
        }
 
66
}