projects
/
platform
/
core
/
csapi
/
tizenfx.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Review Elmsharp API cs files
[platform/core/csapi/tizenfx.git]
/
src
/
ElmSharp
/
ElmSharp
/
EcoreMainloop.cs
diff --git
a/src/ElmSharp/ElmSharp/EcoreMainloop.cs
b/src/ElmSharp/ElmSharp/EcoreMainloop.cs
old mode 100755
(executable)
new mode 100644
(file)
index
505e2c0
..
00660cb
--- a/
src/ElmSharp/ElmSharp/EcoreMainloop.cs
+++ b/
src/ElmSharp/ElmSharp/EcoreMainloop.cs
@@
-15,16
+15,18
@@
*/
using System;
*/
using System;
-using System.Collections.
Generic
;
+using System.Collections.
Concurrent
;
namespace ElmSharp
{
/// <summary>
namespace ElmSharp
{
/// <summary>
- /// 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.
/// </summary>
/// </summary>
+ /// <since_tizen> preview </since_tizen>
public static class EcoreMainloop
{
public static class EcoreMainloop
{
- static readonly Dictionary<int, Func<bool>> _taskMap = new Dictionary<int, Func<bool>>();
+
+ static readonly ConcurrentDictionary<int, Func<bool>> _taskMap = new ConcurrentDictionary<int, Func<bool>>();
static readonly Object _taskLock = new Object();
static int _newTaskId = 0;
static readonly Object _taskLock = new Object();
static int _newTaskId = 0;
@@
-40,20
+42,23
@@
namespace ElmSharp
/// <summary>
/// Checks if you are calling this function from the main thread.
/// </summary>
/// <summary>
/// Checks if you are calling this function from the main thread.
/// </summary>
- /// <remarks>True is the calling function is the same thread, false otherwise.</remarks>
+ /// <remarks>True if the calling function is the same thread, false otherwise.</remarks>
+ /// <since_tizen> preview </since_tizen>
public static bool IsMainThread => Interop.Eina.eina_main_loop_is();
/// <summary>
/// Runs the application main loop.
/// </summary>
public static bool IsMainThread => Interop.Eina.eina_main_loop_is();
/// <summary>
/// Runs the application main loop.
/// </summary>
+ /// <since_tizen> preview </since_tizen>
public static void Begin()
{
Interop.Ecore.ecore_main_loop_begin();
}
/// <summary>
public static void Begin()
{
Interop.Ecore.ecore_main_loop_begin();
}
/// <summary>
- /// 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.
/// </summary>
/// </summary>
+ /// <since_tizen> preview </since_tizen>
public static void Quit()
{
Interop.Ecore.ecore_main_loop_quit();
public static void Quit()
{
Interop.Ecore.ecore_main_loop_quit();
@@
-62,7
+67,8
@@
namespace ElmSharp
/// <summary>
/// Adds an idler handler.
/// </summary>
/// <summary>
/// Adds an idler handler.
/// </summary>
- /// <param name="task">The action to call when idling</param>
+ /// <param name="task">The action to call when idle.</param>
+ /// <since_tizen> preview </since_tizen>
public static void Post(Action task)
{
int id = RegistHandler(() => { task(); return false; });
public static void Post(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@
-70,9
+76,10
@@
namespace ElmSharp
}
/// <summary>
}
/// <summary>
- /// Calls callback asynchronously in the main loop.
+ /// Calls
the
callback asynchronously in the main loop.
/// </summary>
/// </summary>
- /// <param name="task">The action wanted to be called</param>
+ /// <param name="task">The action wanted to be called.</param>
+ /// <since_tizen> preview </since_tizen>
public static void PostAndWakeUp(Action task)
{
int id = RegistHandler(() => { task(); return false; });
public static void PostAndWakeUp(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@
-80,9
+87,10
@@
namespace ElmSharp
}
/// <summary>
}
/// <summary>
- /// Calls callback synchronously in the main loop.
+ /// Calls
the
callback synchronously in the main loop.
/// </summary>
/// </summary>
- /// <param name="task">The action wanted to be called</param>
+ /// <param name="task">The action wanted to be called.</param>
+ /// <since_tizen> preview </since_tizen>
public static void Send(Action task)
{
int id = RegistHandler(() => { task(); return false; });
public static void Send(Action task)
{
int id = RegistHandler(() => { task(); return false; });
@@
-94,7
+102,8
@@
namespace ElmSharp
/// </summary>
/// <param name="interval">The interval in seconds.</param>
/// <param name="handler">The given function.</param>
/// </summary>
/// <param name="interval">The interval in seconds.</param>
/// <param name="handler">The given function.</param>
- /// <returns>A timer object handler on success, NULL on failure.</returns>
+ /// <returns>A timer object handler on success, or null on failure.</returns>
+ /// <since_tizen> preview </since_tizen>
public static IntPtr AddTimer(double interval, Func<bool> handler)
{
int id = RegistHandler(handler);
public static IntPtr AddTimer(double interval, Func<bool> handler)
{
int id = RegistHandler(handler);
@@
-105,10
+114,12
@@
namespace ElmSharp
/// Removes the specified timer from the timer list.
/// </summary>
/// <param name="id">The specified timer handler</param>
/// Removes the specified timer from the timer list.
/// </summary>
/// <param name="id">The specified timer handler</param>
+ /// <since_tizen> preview </since_tizen>
public static void RemoveTimer(IntPtr id)
{
int taskId = (int)Interop.Ecore.ecore_timer_del(id);
public static void RemoveTimer(IntPtr id)
{
int taskId = (int)Interop.Ecore.ecore_timer_del(id);
- _taskMap.Remove(taskId);
+ Func<bool> unused;
+ _taskMap.TryRemove(taskId, out unused);
}
static int RegistHandler(Func<bool> task)
}
static int RegistHandler(Func<bool> task)
@@
-131,11
+142,14
@@
namespace ElmSharp
bool result = false;
if (userAction != null)
bool result = false;
if (userAction != null)
+ {
result = userAction();
result = userAction();
+ }
- if (result == false)
- _taskMap.Remove(task_id);
-
+ if (!result)
+ {
+ _taskMap.TryRemove(task_id, out userAction);
+ }
return result;
}
return false;
return result;
}
return false;