ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # ignite-496
Date Thu, 19 Mar 2015 04:38:40 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-496 26989ad51 -> f6913288f


# ignite-496


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f6913288
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f6913288
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f6913288

Branch: refs/heads/ignite-496
Commit: f6913288f3fd742d65f1e8fafd82b7aad3824b7f
Parents: 26989ad
Author: sboikov <semen.boikov@inria.fr>
Authored: Thu Mar 19 07:38:38 2015 +0300
Committer: sboikov <semen.boikov@inria.fr>
Committed: Thu Mar 19 07:38:38 2015 +0300

----------------------------------------------------------------------
 .../src/ignite_cache.cpp                        | 34 ++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f6913288/modules/interop/src/main/cpp/ignite-interop/ignite-nodejs-prototype/src/ignite_cache.cpp
----------------------------------------------------------------------
diff --git a/modules/interop/src/main/cpp/ignite-interop/ignite-nodejs-prototype/src/ignite_cache.cpp
b/modules/interop/src/main/cpp/ignite-interop/ignite-nodejs-prototype/src/ignite_cache.cpp
index 4b218e2..32a6f6d 100644
--- a/modules/interop/src/main/cpp/ignite-interop/ignite-nodejs-prototype/src/ignite_cache.cpp
+++ b/modules/interop/src/main/cpp/ignite-interop/ignite-nodejs-prototype/src/ignite_cache.cpp
@@ -132,25 +132,34 @@ void IgniteCache::Put(const FunctionCallbackInfo<Value>& args)
{
 struct AsyncData
 {
 	Persistent<Function> cb;
+
+	uv_async_t *async;
 };
 
-void noop(uv_work_t* req)
+void QueueWorkNoop(uv_work_t* req)
 {
 }
 
-void AfterExecute(uv_work_t *req)
+void AfterQueueWork(uv_work_t* req)
 {
+}
 
+void freeCallback(uv_async_t *async) {
+	delete async;
 }
 
-void asyncCallback(AsyncData* asyncData)
+void AfterExecute(uv_async_t *async)
 {
 	Isolate* isolate = Isolate::GetCurrent();
 
 	HandleScope scope(isolate);
 
+	AsyncData* asyncData = (AsyncData*)async->data;
+
+	uv_close((uv_handle_t*)async, (uv_close_cb)freeCallback);
+
 	Local<Function> cb = Local<Function>::New(isolate, asyncData->cb);
-	
+
 	asyncData->cb.Reset();
 
 	delete asyncData;
@@ -164,10 +173,15 @@ void asyncCallback(AsyncData* asyncData)
 	node::MakeCallback(isolate,
 		isolate->GetCurrentContext()->Global(),
 		cb,
-		argc, 
+		argc,
 		argv);
 }
 
+void igniteAsyncCallback(AsyncData* asyncData)
+{
+	uv_async_send(asyncData->async);
+}
+
 void IgniteCache::PutAsync(const FunctionCallbackInfo<Value>& args) {
 	Isolate* isolate = Isolate::GetCurrent();
 	HandleScope scope(isolate);
@@ -196,9 +210,17 @@ void IgniteCache::PutAsync(const FunctionCallbackInfo<Value>&
args) {
 	out.writeInt32(key);
 	out.writeInt32(val);
 
+	uv_async_t* async = new uv_async_t();
+	
+	async->data = asyncData;
+
+	asyncData->async = async;
+
+	uv_async_init(uv_default_loop(), async, AfterExecute);
+
 	cache->cache->put(out.data(), out.size());
 
-	uv_queue_work(uv_default_loop(), 0, noop, (uv_after_work_cb)AfterExecute);
+	// uv_queue_work(uv_default_loop(), 0, QueueWorkNoop, (uv_after_work_cb)AfterQueueWork);
 
 	//obj->value_ += 1;
 	//args.GetReturnValue().Set(Number::New(isolate, obj->value_));


Mime
View raw message