Commit 48a9707
Changed files (16)
product
infrastructure
product/infrastructure/threading/IThread.cs → product/infrastructure/threading/ApplicationThread.cs
@@ -1,6 +1,6 @@
namespace gorilla.infrastructure.threading
{
- public interface IThread
+ public interface ApplicationThread
{
T provide_slot_for<T>() where T : class, new();
}
product/infrastructure/threading/BackgroundThread.cs
@@ -0,0 +1,6 @@
+using gorilla.utility;
+
+namespace gorilla.infrastructure.threading
+{
+ public interface BackgroundThread : DisposableCommand {}
+}
\ No newline at end of file
product/infrastructure/threading/BackgroundThreadFactory.cs
@@ -6,8 +6,8 @@ namespace gorilla.infrastructure.threading
{
public interface IBackgroundThreadFactory
{
- IBackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand;
- IBackgroundThread create_for(Action action);
+ BackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand;
+ BackgroundThread create_for(Action action);
}
public class BackgroundThreadFactory : IBackgroundThreadFactory
@@ -19,12 +19,12 @@ namespace gorilla.infrastructure.threading
this.registry = registry;
}
- public IBackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand
+ public BackgroundThread create_for<CommandToExecute>() where CommandToExecute : DisposableCommand
{
return new WorkderBackgroundThread(registry.get_a<CommandToExecute>());
}
- public IBackgroundThread create_for(Action action)
+ public BackgroundThread create_for(Action action)
{
return new WorkderBackgroundThread(new AnonymousDisposableCommand(action));
}
product/infrastructure/threading/CurrentThread.cs
@@ -2,7 +2,7 @@
namespace gorilla.infrastructure.threading
{
- public class CurrentThread : IThread
+ public class CurrentThread : ApplicationThread
{
public T provide_slot_for<T>() where T : class, new()
{
product/infrastructure/threading/IntervalTimer.cs
@@ -1,19 +1,12 @@
using System;
using System.Collections.Generic;
-using System.Timers;
namespace gorilla.infrastructure.threading
{
- public interface ITimer
- {
- void start_notifying(ITimerClient client_to_be_notified, TimeSpan span);
- void stop_notifying(ITimerClient client_to_stop_notifying);
- }
-
- public class IntervalTimer : ITimer
+ public class IntervalTimer : Timer
{
readonly ITimerFactory factory;
- readonly IDictionary<ITimerClient, Timer> timers;
+ readonly IDictionary<TimerClient, System.Timers.Timer> timers;
public IntervalTimer() : this(new TimerFactory())
{
@@ -22,15 +15,15 @@ namespace gorilla.infrastructure.threading
public IntervalTimer(ITimerFactory factory)
{
this.factory = factory;
- timers = new Dictionary<ITimerClient, Timer>();
+ timers = new Dictionary<TimerClient, System.Timers.Timer>();
}
- public void start_notifying(ITimerClient client_to_be_notified, TimeSpan span)
+ public void start_notifying(TimerClient client_to_be_notified, TimeSpan span)
{
stop_notifying(client_to_be_notified);
var timer = factory.create_for(span);
- timer.Elapsed += (sender, args) =>
+ timer.Elapsed += (o, e) =>
{
client_to_be_notified.notify();
};
@@ -38,7 +31,7 @@ namespace gorilla.infrastructure.threading
timers[client_to_be_notified] = timer;
}
- public void stop_notifying(ITimerClient client_to_stop_notifying)
+ public void stop_notifying(TimerClient client_to_stop_notifying)
{
if (!timers.ContainsKey(client_to_stop_notifying)) return;
timers[client_to_stop_notifying].Stop();
product/infrastructure/threading/ITimerFactory.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace gorilla.infrastructure.threading
+{
+ public interface ITimerFactory
+ {
+ System.Timers.Timer create_for(TimeSpan span);
+ }
+}
\ No newline at end of file
product/infrastructure/threading/PerThreadScopedStorage.cs
@@ -3,11 +3,11 @@ using gorilla.utility;
namespace gorilla.infrastructure.threading
{
- public class PerThreadScopedStorage : IScopedStorage
+ public class PerThreadScopedStorage : ScopedStorage
{
- readonly IThread current_thread;
+ readonly ApplicationThread current_thread;
- public PerThreadScopedStorage(IThread current_thread)
+ public PerThreadScopedStorage(ApplicationThread current_thread)
{
this.current_thread = current_thread;
}
product/infrastructure/threading/ThreadingExtensions.cs
@@ -4,7 +4,7 @@ namespace gorilla.infrastructure.threading
{
static public class ThreadingExtensions
{
- static public IBackgroundThread on_a_background_thread(this DisposableCommand command)
+ static public BackgroundThread on_a_background_thread(this DisposableCommand command)
{
return new WorkderBackgroundThread(command);
}
product/infrastructure/threading/Timer.cs
@@ -0,0 +1,10 @@
+using System;
+
+namespace gorilla.infrastructure.threading
+{
+ public interface Timer
+ {
+ void start_notifying(TimerClient client_to_be_notified, TimeSpan span);
+ void stop_notifying(TimerClient client_to_stop_notifying);
+ }
+}
\ No newline at end of file
product/infrastructure/threading/ITimerClient.cs → product/infrastructure/threading/TimerClient.cs
@@ -1,6 +1,6 @@
namespace gorilla.infrastructure.threading
{
- public interface ITimerClient
+ public interface TimerClient
{
void notify();
}
product/infrastructure/threading/TimerFactory.cs
@@ -1,22 +1,17 @@
using System;
-using System.Timers;
-namespace gorilla.infrastructure.threading
-{
- public interface ITimerFactory
- {
- Timer create_for(TimeSpan span);
- }
-
- public class TimerFactory : ITimerFactory
- {
- public Timer create_for(TimeSpan span)
- {
- if (span.Seconds > 0) {
- var milliseconds = span.Seconds*1000;
- return new Timer(milliseconds);
- }
- return new Timer(span.Ticks);
- }
- }
+namespace gorilla.infrastructure.threading
+{
+ public class TimerFactory : ITimerFactory
+ {
+ public System.Timers.Timer create_for(TimeSpan span)
+ {
+ if (span.Seconds > 0)
+ {
+ var milliseconds = span.Seconds*1000;
+ return new System.Timers.Timer(milliseconds);
+ }
+ return new System.Timers.Timer(span.Ticks);
+ }
+ }
}
\ No newline at end of file
product/infrastructure/threading/WorkderBackgroundThread.cs
@@ -1,10 +1,8 @@
using gorilla.utility;
namespace gorilla.infrastructure.threading
-{
- public interface IBackgroundThread : DisposableCommand {}
-
- public class WorkderBackgroundThread : IBackgroundThread
+{
+ public class WorkderBackgroundThread : BackgroundThread
{
readonly IWorkerThread worker_thread;
product/infrastructure/infrastructure.csproj
@@ -91,13 +91,16 @@
<Compile Include="reflection\Assembly.cs" />
<Compile Include="registries\DefaultRegistry.cs" />
<Compile Include="threading\AsynchronousCommandProcessor.cs" />
+ <Compile Include="threading\BackgroundThread.cs" />
+ <Compile Include="threading\ITimerFactory.cs" />
+ <Compile Include="threading\Timer.cs" />
<Compile Include="threading\WorkderBackgroundThread.cs" />
<Compile Include="threading\BackgroundThreadFactory.cs" />
<Compile Include="threading\CommandProcessor.cs" />
<Compile Include="threading\CurrentThread.cs" />
<Compile Include="threading\IntervalTimer.cs" />
- <Compile Include="threading\IThread.cs" />
- <Compile Include="threading\ITimerClient.cs" />
+ <Compile Include="threading\ApplicationThread.cs" />
+ <Compile Include="threading\TimerClient.cs" />
<Compile Include="threading\IWorkerThread.cs" />
<Compile Include="threading\PerThread.cs" />
<Compile Include="threading\PerThreadScopedStorage.cs" />
product/utility/ScopedContext.cs
@@ -2,9 +2,9 @@
{
public class ScopedContext : Context
{
- IScopedStorage storage;
+ ScopedStorage storage;
- public ScopedContext(IScopedStorage storage)
+ public ScopedContext(ScopedStorage storage)
{
this.storage = storage;
}
product/utility/IScopedStorage.cs → product/utility/ScopedStorage.cs
@@ -2,7 +2,7 @@
namespace gorilla.utility
{
- public interface IScopedStorage
+ public interface ScopedStorage
{
IDictionary provide_storage();
}
product/utility/utility.csproj
@@ -85,7 +85,7 @@
<Compile Include="Factory.cs" />
<Compile Include="Identifiable.cs" />
<Compile Include="Import.cs" />
- <Compile Include="IScopedStorage.cs" />
+ <Compile Include="ScopedStorage.cs" />
<Compile Include="Key.cs" />
<Compile Include="Mapper.cs" />
<Compile Include="Notification.cs" />