X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FElmSharp%2FElmSharp%2FEcoreMainloop.cs;h=00660cbd123ed0f03f195c58d5faf5257823b350;hb=4a9d296866c560d5b83b1e16dd27beba8f7caa59;hp=505e2c0faef505201f22bc95bd65a92fadd4ff13;hpb=db5d8a6993614cfd3d001e2b441789a9d6dc7b23;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/ElmSharp/ElmSharp/EcoreMainloop.cs b/src/ElmSharp/ElmSharp/EcoreMainloop.cs
old mode 100755
new mode 100644
index 505e2c0..00660cb
--- a/src/ElmSharp/ElmSharp/EcoreMainloop.cs
+++ b/src/ElmSharp/ElmSharp/EcoreMainloop.cs
@@ -15,16 +15,18 @@
*/
using System;
-using System.Collections.Generic;
+using System.Collections.Concurrent;
namespace ElmSharp
{
///
- /// EcoreMainloop is a helper class, it provide functions relative Ecore's main loop.
+ /// EcoreMainloop is a helper class, which provides the functions relative to Ecore's main loop.
///
+ /// preview
public static class EcoreMainloop
{
- static readonly Dictionary> _taskMap = new Dictionary>();
+
+ static readonly ConcurrentDictionary> _taskMap = new ConcurrentDictionary>();
static readonly Object _taskLock = new Object();
static int _newTaskId = 0;
@@ -40,20 +42,23 @@ namespace ElmSharp
///
/// Checks if you are calling this function from the main thread.
///
- /// True is the calling function is the same thread, false otherwise.
+ /// True if the calling function is the same thread, false otherwise.
+ /// preview
public static bool IsMainThread => Interop.Eina.eina_main_loop_is();
///
/// Runs the application main loop.
///
+ /// preview
public static void Begin()
{
Interop.Ecore.ecore_main_loop_begin();
}
///
- /// Quits the main loop once all the events currently on the queue have been processed.
+ /// Quits the main loop, once all the events currently on the queue have been processed.
///
+ /// preview
public static void Quit()
{
Interop.Ecore.ecore_main_loop_quit();
@@ -62,7 +67,8 @@ namespace ElmSharp
///
/// Adds an idler handler.
///
- /// The action to call when idling
+ /// The action to call when idle.
+ /// preview
public static void Post(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@ -70,9 +76,10 @@ namespace ElmSharp
}
///
- /// Calls callback asynchronously in the main loop.
+ /// Calls the callback asynchronously in the main loop.
///
- /// The action wanted to be called
+ /// The action wanted to be called.
+ /// preview
public static void PostAndWakeUp(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@ -80,9 +87,10 @@ namespace ElmSharp
}
///
- /// Calls callback synchronously in the main loop.
+ /// Calls the callback synchronously in the main loop.
///
- /// The action wanted to be called
+ /// The action wanted to be called.
+ /// preview
public static void Send(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@ -94,7 +102,8 @@ namespace ElmSharp
///
/// The interval in seconds.
/// The given function.
- /// A timer object handler on success, NULL on failure.
+ /// A timer object handler on success, or null on failure.
+ /// preview
public static IntPtr AddTimer(double interval, Func handler)
{
int id = RegistHandler(handler);
@@ -105,10 +114,12 @@ namespace ElmSharp
/// Removes the specified timer from the timer list.
///
/// The specified timer handler
+ /// preview
public static void RemoveTimer(IntPtr id)
{
int taskId = (int)Interop.Ecore.ecore_timer_del(id);
- _taskMap.Remove(taskId);
+ Func unused;
+ _taskMap.TryRemove(taskId, out unused);
}
static int RegistHandler(Func task)
@@ -131,11 +142,14 @@ namespace ElmSharp
bool result = false;
if (userAction != null)
+ {
result = userAction();
+ }
- if (result == false)
- _taskMap.Remove(task_id);
-
+ if (!result)
+ {
+ _taskMap.TryRemove(task_id, out userAction);
+ }
return result;
}
return false;