示例#1
0
/*
 * Create main Fiber. There is always a main Fiber for a given (real) thread,
 * and it's parent is always NULL.
 */
static Fiber *
fiber_create_main(void)
{
    Fiber *t_main;
    PyObject *dict = PyThreadState_GetDict();
    PyTypeObject *cls = (PyTypeObject *)&FiberType;

    if (dict == NULL) {
        if (!PyErr_Occurred()) {
            PyErr_NoMemory();
        }
        return NULL;
    }

    /* create the main Fiber for this thread */
    t_main = (Fiber *)cls->tp_new(cls, NULL, NULL);
    if (!t_main) {
        return NULL;
    }
    Py_INCREF(dict);
    t_main->ts_dict = dict;
    t_main->parent = NULL;
    t_main->thread_h = stacklet_newthread();
    t_main->stacklet_h = NULL;
    t_main->initialized = True;
    t_main->is_main = True;
    return t_main;
}
示例#2
0
文件: tests.c 项目: Debug-Orz/Sypy
int main(int argc, char **argv)
{
  test_t *tst;
  if (argc > 1)
    srand(atoi(argv[1]));

  thrd = stacklet_newthread();
  for (tst=test_list; tst->runtest; tst++)
    {
      printf("+++ Running %s... +++\n", tst->name);
      tst->runtest();
    }
  stacklet_deletethread(thrd);
  printf("+++ All ok. +++\n");
  return 0;
}