Skip to content

Commit b8e1058

Browse files
committed
refactor(callbacks)!: wip, using the new VM::resolve instead of the deprecated one
1 parent ab5b3b3 commit b8e1058

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

draft/database/src/sqlite3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace Database
9595
// For each row returned from the SQL query, run the user's callback
9696
// function on each row passing in an Ark List of the row results.
9797
for (std::vector<Value>& row : all_results)
98-
vm->resolve(&user_defined_callback, Value(std::move(row)));
98+
vm->resolve(vm->getDefaultContext(), { user_defined_callback, Value(std::move(row)) });
9999

100100
if (code != SQLITE_OK)
101101
{

draft/http/src/server.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Value handle_request_for(std::string_view funcname, HttpMethod_t handler, std::v
2222
Server& srv = create_server();
2323

2424
(srv.*handler)(n[0].string().c_str(), [funcname, n, vm](const Request& req, Response& res) {
25+
// todo: find a way to have 1 execution context per thread. Should we use a lock?
26+
// Pre-create as many execution contexts as threads inside cpp-httplib pool?
27+
// Track contexts that are being used to find the first available one
2528
std::string content;
2629
std::string type;
2730
Value r;
@@ -34,7 +37,7 @@ Value handle_request_for(std::string_view funcname, HttpMethod_t handler, std::v
3437
matches.push_back(Value(req.matches[i]));
3538

3639
if (req.params.size() == 0)
37-
r = vm->resolve(&n[1], matches, req.body, Nil);
40+
r = Nil; // fixme: vm->resolve(&n[1], matches, req.body, Nil);
3841
else
3942
{
4043
// craft params
@@ -43,7 +46,7 @@ Value handle_request_for(std::string_view funcname, HttpMethod_t handler, std::v
4346

4447
Value params = Value(UserType(&p.back(), get_cfs_param()));
4548

46-
r = vm->resolve(&n[1], matches, req.body, params);
49+
r = Nil; // fixme: vm->resolve(&n[1], matches, req.body, params);
4750
}
4851
}
4952
// no matches, maybe params
@@ -55,11 +58,11 @@ Value handle_request_for(std::string_view funcname, HttpMethod_t handler, std::v
5558

5659
Value params = Value(UserType(&p.back(), get_cfs_param()));
5760

58-
r = vm->resolve(&n[1], Nil, req.body, params);
61+
r = Nil; // fixme: vm->resolve(&n[1], Nil, req.body, params);
5962
}
6063
// no matches, no params
6164
else
62-
r = vm->resolve(&n[1], Nil, req.body, Nil);
65+
r = Nil; // fixme: vm->resolve(&n[1], Nil, req.body, Nil);
6366

6467
if (CHECK_FUNC_RETURN_VAL_FOR_REQ(r))
6568
{

0 commit comments

Comments
 (0)