##// END OF EJS Templates
sync, minor changes
cin -
r284:bcb6c16f6fed v3
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,6 +1,7
1 using System;
1 using System;
2 using System.Collections.Generic;
2 using System.Collections.Generic;
3 using System.Diagnostics;
3 using System.Diagnostics;
4 using System.Dynamic;
4 using System.Linq;
5 using System.Linq;
5 using Implab.Components;
6 using Implab.Components;
6 using Implab.Diagnostics;
7 using Implab.Diagnostics;
@@ -91,11 +92,13 namespace Implab.Playground {
91 static void Main(string[] args) {
92 static void Main(string[] args) {
92 var u1 = new Uri("/some/one");
93 var u1 = new Uri("/some/one");
93
94
94 Console.WriteLine($"{u1.IsAbsoluteUri}: {u1}");
95 dynamic obj = new ExpandoObject();
96
97 obj.Name = "Dynamo";
95
98
96 var u2 = new Uri(u1, "../../two");
99 obj.Hello = new Func<string>(() => { return "Hello"; });
97
100
98 Console.WriteLine($"{u2.IsAbsoluteUri}: {u2}");
101 Console.WriteLine($"{obj.Hello()}");
99
102
100 }
103 }
101
104
1 NO CONTENT: file renamed from Implab.ServiceHost/docs/XmlConfiguration.md to Implab.ServiceHost/docs/XmlConfiguration.ru.md
NO CONTENT: file renamed from Implab.ServiceHost/docs/XmlConfiguration.md to Implab.ServiceHost/docs/XmlConfiguration.ru.md
@@ -46,6 +46,10 namespace Implab.Components {
46
46
47 protected override async Task StopInternalAsync(CancellationToken ct) {
47 protected override async Task StopInternalAsync(CancellationToken ct) {
48 // component in Stopping state, no new polls will be scheduled
48 // component in Stopping state, no new polls will be scheduled
49
50 // we do not need additional synchronization logic here
51 // since RunnableComponent already done this
52
49 m_cancellation.Cancel();
53 m_cancellation.Cancel();
50 try {
54 try {
51 // await for pending poll
55 // await for pending poll
@@ -59,7 +63,10 namespace Implab.Components {
59 protected abstract Task Poll(CancellationToken ct);
63 protected abstract Task Poll(CancellationToken ct);
60
64
61 void ScheduleNextPoll(int timeout) {
65 void ScheduleNextPoll(int timeout) {
66 // access and modification of the component state
67 // in custom methods requires a synchronization
62 lock (SynchronizationObject) {
68 lock (SynchronizationObject) {
69
63 if (State == ExecutionState.Running) {
70 if (State == ExecutionState.Running) {
64 m_pending = Safe.CreateTask(m_cancellation.Token);
71 m_pending = Safe.CreateTask(m_cancellation.Token);
65 m_poll = m_pending.Then(() => Poll(m_cancellation.Token));
72 m_poll = m_pending.Then(() => Poll(m_cancellation.Token));
@@ -70,10 +77,16 namespace Implab.Components {
70
77
71 async void OnTimer(object state) {
78 async void OnTimer(object state) {
72 try {
79 try {
80 // changes to m_pending and m_poll are done
81 // only in ScheduleNextPoll method, hence we
82 // can safely use them here
73 m_pending.Start();
83 m_pending.Start();
74 await m_poll;
84 await m_poll;
85
86 // schedule next poll
75 ScheduleNextPoll(Interval);
87 ScheduleNextPoll(Interval);
76 } catch (Exception e) {
88 } catch (Exception e) {
89 // hanle error
77 UnhandledException.DispatchEvent(this, new UnhandledExceptionEventArgs(e, false));
90 UnhandledException.DispatchEvent(this, new UnhandledExceptionEventArgs(e, false));
78
91
79 if (FailOnError)
92 if (FailOnError)
1 NO CONTENT: file was removed
NO CONTENT: file was removed
The requested commit or file is too big and content was truncated. Show full diff
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now