annotate Implab/Component.cs @ 119:2573b562e328 v2

Promises rewritten, added improved version of AsyncQueue
author cin
date Sun, 11 Jan 2015 19:13:02 +0300
parents fe33f4e02ad5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
1 using System;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
2 using System.Collections.Generic;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
3 using System.Linq;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
4 using System.Web;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
5
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
6 namespace Implab {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
7 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
8 /// Компоненты являются состовными объектами, имеют детерминированный период жизни, автоматически освобождают ресурсы входящие в них.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
9 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
10 /// <remarks>Компонента управляет временем жизни включенных в нее компонент</remarks>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
11 public class Component: Disposable {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
12 LinkedList<IDisposable> m_components = new LinkedList<IDisposable>();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
13
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
14 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
15 /// Коллекция компонент, из которых состоит текущая компонента.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
16 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
17 public ICollection<IDisposable> Components {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
18 get {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
19 AssertNotDisposed();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
20 return m_components;
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
21 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
22 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
23
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
24 /// <summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
25 /// Освобождает компоненты, входящие в состав текущей компоненты.
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
26 /// </summary>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
27 /// <param name="disposing">Признак того, что происходит освобождение ресурсов.</param>
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
28 protected override void Dispose(bool disposing) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
29 if (disposing) {
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
30 foreach (var item in m_components)
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
31 item.Dispose();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
32 m_components.Clear();
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
33 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
34 base.Dispose(disposing);
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
35 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
36 }
fe33f4e02ad5 improved tracing
cin
parents:
diff changeset
37 }