Skip to content

Commit

Permalink
Add local computation as third chance
Browse files Browse the repository at this point in the history
  • Loading branch information
blacksheeep committed May 30, 2014
1 parent c9e993a commit a974ae0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion krivine-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ new_config(char *prog, struct environment_s *global_dict, int thunk_request, int
ret->start_request = start_request;
ret->prefix = prefix;
ret->thunk = 0;
ret->local_done = 0;
ret->thunk_time = NFN_DEFAULT_WAITING_TIME;
return ret;
}
Expand Down Expand Up @@ -163,7 +164,7 @@ add_computation_components(struct ccnl_prefix_s *prefix, int thunk_request, unsi
}

struct ccnl_prefix_s *
add_local_computation_components(struct ccnl_prefix_s *prefix, struct configuration_s *config){
add_local_computation_components(struct configuration_s *config){

int i = 0;
char *comp = malloc(CCNL_MAX_PACKET_SIZE);
Expand Down
1 change: 1 addition & 0 deletions krivine-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct fox_machine_state_s{
struct configuration_s{
int configid;
int start_request;
int local_done;
char *prog;
struct stack_s *result_stack;
struct stack_s *argument_stack;
Expand Down
15 changes: 12 additions & 3 deletions krivine.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ create_namecomps(struct ccnl_relay_s *ccnl, struct configuration_s *config, int

if(ccnl_nfn_local_content_search(ccnl, config, prefix)){ //local computation name components
DEBUGMSG(99, "content local available\n");
return add_local_computation_components(prefix, config);
return add_local_computation_components(config);
}
else{ //network search name components
unsigned char *comp = malloc(CCNL_MAX_PACKET_SIZE);
Expand Down Expand Up @@ -777,7 +777,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,

//check if last result is now available
int compcnt = 0;
recontinue:
recontinue: //loop by reentering after timeout of the interest...
if(local_search){
parameter_number = choose_parameter(config);
struct ccnl_prefix_s *pref = create_namecomps(ccnl, config, parameter_number, thunk_request, config->fox_state->params[parameter_number]->content);
Expand All @@ -787,7 +787,7 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
//result was not delivered --> choose next parameter
++config->fox_state->it_routable_param;
parameter_number = choose_parameter(config);
if(parameter_number < 0) return NULL; //no more parameter --> no result found, can try a local computation
if(parameter_number < 0) goto local_compute; //no more parameter --> no result found, can try a local computation
//TODO: create new prefix with name components!!!!
struct ccnl_prefix_s *pref = create_namecomps(ccnl, config, parameter_number, thunk_request, config->fox_state->params[parameter_number]->content);
c = ccnl_nfn_local_content_search(ccnl, config, pref);
Expand All @@ -800,6 +800,15 @@ ZAM_term(struct ccnl_relay_s *ccnl, struct configuration_s *config,
*halt = -1; //set halt to -1 for async computations
if(*halt < 0) return prog;

local_compute:
if(config->local_done){
return NULL;
}
config->local_done = 1;
pref = add_local_computation_components(config);
interest = mkInterestObject(ccnl, config, pref);
ccnl_interest_propagate(ccnl, interest);

handlecontent: //if result was found ---> handle it
if(c){
if(thunk_request){ //if thunk_request push thunkid on the stack
Expand Down

0 comments on commit a974ae0

Please sign in to comment.