diff options
author | 2017-09-22 09:28:25 +0200 | |
---|---|---|
committer | 2017-10-09 14:08:32 +0200 | |
commit | 59d4e6a0654d361de19fbbfa65daf6c1dabd55a0 (patch) | |
tree | acf7a1c526bbe760d6ce855e4eb18545d58ffeda /src | |
parent | ce23b9e7ff8443c46ed21804277d8db90671a3b4 (diff) |
Remove unused files
Change-Id: I922d69d8d2834a4aeebf06a925455ea7c28a1642
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src')
-rw-r--r-- | src/afb-thread.c | 60 | ||||
-rw-r--r-- | src/afb-thread.h | 23 | ||||
-rw-r--r-- | src/tests/test-thread.c | 121 | ||||
-rwxr-xr-x | src/tests/test-thread.sh | 4 |
4 files changed, 0 insertions, 208 deletions
diff --git a/src/afb-thread.c b/src/afb-thread.c deleted file mode 100644 index 67870ce6..00000000 --- a/src/afb-thread.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2016, 2017 "IoT.bzh" - * Author José Bollo <jose.bollo@iot.bzh> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define _GNU_SOURCE - -#include <string.h> - -#include <afb/afb-req-itf.h> - -#include "afb-thread.h" -#include "jobs.h" -#include "sig-monitor.h" -#include "verbose.h" - -static void req_call(int signum, void *arg1, void *arg2, void *arg3) -{ - struct afb_req req = { .itf = arg1, .closure = arg2 }; - void (*callback)(struct afb_req) = arg3; - - if (signum != 0) - afb_req_fail_f(req, "aborted", "signal %s(%d) caught", strsignal(signum), signum); - else - callback(req); - afb_req_unref(req); -} - -void afb_thread_req_call(struct afb_req req, void (*callback)(struct afb_req req), int timeout, void *group) -{ - int rc; - - afb_req_addref(req); - if (0) { - /* no threading */ - sig_monitor3(timeout, req_call, (void*)req.itf, req.closure, callback); - } else { - /* threading */ - rc = jobs_queue3(group, timeout, req_call, (void*)req.itf, req.closure, callback); - if (rc < 0) { - /* TODO: allows or not to proccess it directly as when no threading? (see above) */ - ERROR("can't process job with threads: %m"); - afb_req_fail_f(req, "cancelled", "not able to pipe a job for the task"); - afb_req_unref(req); - } - } -} - diff --git a/src/afb-thread.h b/src/afb-thread.h deleted file mode 100644 index 4e44b55e..00000000 --- a/src/afb-thread.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2016, 2017 "IoT.bzh" - * Author José Bollo <jose.bollo@iot.bzh> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -struct afb_req; - -extern void afb_thread_req_call(struct afb_req req, void (*callback)(struct afb_req req), int timeout, void *group); - diff --git a/src/tests/test-thread.c b/src/tests/test-thread.c deleted file mode 100644 index d3ce08c1..00000000 --- a/src/tests/test-thread.c +++ /dev/null @@ -1,121 +0,0 @@ -#define _GNU_SOURCE -#include <stdio.h> -#include <pthread.h> -#include <time.h> -#include <unistd.h> -#include <sys/syscall.h> - -#include <afb/afb-req-itf.h> -#include "../afb-thread.h" -#include "../jobs.h" - -struct foo { - int value; - int refcount; -}; - -void addref(void *closure) -{ - struct foo *foo = closure; - foo->refcount++; -} - -void unref(void *closure) -{ - struct foo *foo = closure; - if(!--foo->refcount) { - /* printf("%06d FREE\n", foo->value); */ - free(foo); - } -} - -void fail(void *closure, const char *status, const char *info) -{ - struct foo *foo = closure; - printf("%06d ABORT T%d %s\n", foo->value, (int)syscall(SYS_gettid), status); -} - -struct afb_req_itf itf = { - .json = NULL, - .get = NULL, - - .success = NULL, - .fail = fail, - - .raw = NULL, - .send = NULL, - - .context_get = NULL, - .context_set = NULL, - - .addref = addref, - .unref = unref, - - .session_close = NULL, - .session_set_LOA = NULL, - - .subscribe = NULL, - .unsubscribe = NULL, - - .subcall = NULL -}; - -void process(struct afb_req req) -{ - struct timespec ts; - struct foo *foo = req.closure; - printf("%06d PROCESS T%d\n", foo->value, (int)syscall(SYS_gettid)); - ts.tv_sec = 0; - ts.tv_nsec = foo->value * 1000; -// nanosleep(&ts, NULL); -} - -void terminate(int signum) -{ - printf("---------------- TERMINATE T%d (%d)\n", (int)syscall(SYS_gettid), signum); -#if 1 - jobs_terminate(); -#else - jobs_invoke0(0, jobs_terminate); -#endif - exit(0); -} - -void start() -{ - int i; - struct foo *foo; - struct afb_req req; - struct timespec ts; - - req.itf = &itf; - for (i = 0 ; i < 10000 ; i++) { - req.closure = foo = malloc(sizeof *foo); - foo->value = i; - foo->refcount = 1; - afb_thread_req_call(req, process, 5, (&ts) + (i % 7)); - unref(foo); - if (i == 5000) - jobs_queue0(NULL, 0, terminate); - ts.tv_sec = 0; - ts.tv_nsec = 1000000; -// nanosleep(&ts, NULL); - } -} - - - -int main() -{ - int i; - struct foo *foo; - struct afb_req req; - struct timespec ts; - - req.itf = &itf; - jobs_start(4, 0, 20000, start); - return 1; -} - - - diff --git a/src/tests/test-thread.sh b/src/tests/test-thread.sh deleted file mode 100755 index 4ece13c0..00000000 --- a/src/tests/test-thread.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -cc test-thread.c ../afb-thread.c ../verbose.c ../sig-monitor.c ../jobs.c -o test-thread -lrt -lpthread -lsystemd -I../../include -g -./test-thread |