<div class="gmail_quote">On Thu, May 17, 2012 at 6:02 PM, Liam <span dir="ltr"><<a href="mailto:xapian@networkimprov.net" target="_blank">xapian@networkimprov.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div class="im">On Thu, May 17, 2012 at 2:38 AM, Marius Tibeica <span dir="ltr"><<a href="mailto:mtibeica@gmail.com" target="_blank">mtibeica@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have tried multiple approaches. <div>The difficulty comes from the fact that each class can have multiple sync/async functions. For example, Enquire has atleast get_mset, get_matching_terms and get_eset.<div>Another problem is that from the pool methods (which should be templatized) I have to call methods from the class (GetMset_process, GetMset_convert, GetMatchingTerm_process, ...). This means that I also probably have to pass a function as a template parameter.</div>
<div>The thirt problem is that func##_pool and func##_done need to be (int (eio_req *req)), so I can not pass a function pointer.</div><div><br></div><div>At the moment I am trying a hybrid approach (bot templates and macroes). <br>
</div></div></blockquote></div><div><br>OK, no need to bend over backwards. Simplicity is preferable after all. <br></div></div></blockquote><div><br></div><div>I tend to agree. The hybrid approach is even more complicated.</div>
<div><br></div><div><div>template <class dataType, class className></div><div>class PoolHelper</div><div>{</div><div>public:</div><div> ...</div><div> template <Handle<Value> (*convertFunction)(className *data)>;</div>
<div> static void execute_done(eio_req *data)</div><div> {</div><div> HandleScope scope;</div><div> OpInfo* aInfo = (OpInfo*) req->data;</div><div> dataType *aData = (dataType*)aInfo->data;</div><div> AsyncOp<className> *aAsOp = (AsyncOp<className>*)aInfo->op;</div>
<div> Handle<Value> argv[2];</div><div> if (aAsOp->error) {</div><div> argv[0] = Exception::Error(String::New(aAsOp->error->get_msg().c_str()));</div><div> } else {</div><div> argv[0] = Null();</div>
<div> argv[1] = convertFunction(aData);</div><div> }</div><div> tryCallCatch(aAsOp->callback, aAsOp->object->handle_, aAsOp->error ? 1 : 2, argv);</div><div> delete aData;</div><div> delete aAsOp;</div>
<div> delete aInfo;</div><div> }</div><div>};</div><div><br></div><div><br></div><div>#define DECLARE_POOLS(func,classn) \</div><div>...</div><div>static int func##_done(eio_req *req) {\</div><div> HandleScope scope;\</div>
<div> PoolHelper<func##_data,classn>::execute_pool<func##_convert>(req);\</div><div> return 0;\</div><div>}\</div></div><div><br></div><div><br></div><div>I will leave the macro as it is.</div><div><br></div>
<div><br></div><div>The question now is, what's next?</div><div>Should I start implementing other methods?</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div></div></div><br>
<br>_______________________________________________<br>
Xapian-devel mailing list<br>
<a href="mailto:Xapian-devel@lists.xapian.org">Xapian-devel@lists.xapian.org</a><br>
<a href="http://lists.xapian.org/mailman/listinfo/xapian-devel" target="_blank">http://lists.xapian.org/mailman/listinfo/xapian-devel</a><br>
<br></blockquote></div><br>