summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-12-11 12:11:07 -0800
committerVito Caputo <vcaputo@pengaru.com>2018-12-11 12:11:07 -0800
commitf51e6fbbc43cce135e1991f498b4b8b1e7e31129 (patch)
tree085a5b4fd589dadaa45332d82ecc6dcdb8a051db
parentd4f47673d3888e83e2c7373f0cbbcc925ad01278 (diff)
randtest: add test source
-rw-r--r--src/main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..cd71df4
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2018 Vito Caputo - <vcaputo@pengaru.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <pulp.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <thunk.h>
+
+
+THUNK_DEFINE(randy, pulp_t *, p)
+{
+ printf("%i\n", rand());
+ pulp_msleep(p, 1000, NULL);
+ printf("%i\n", rand());
+
+ return 0;
+}
+
+
+int main(int argc, char *argv[])
+{
+ pulp_t *p;
+
+ pulp_init();
+ p = pulp_new();
+
+ for (int i = 0; i < 100; i++)
+ (void) pulp_fiber_new(p, 0, THUNK(randy(p)));
+
+ pulp_run(p);
+ pulp_free(p);
+
+ return 0;
+}
© All Rights Reserved