void init_master_btc_locks() { mzrt_mutex_create(&master_btc_lock); mzrt_sema_create(&master_btc_sema, 0); }
Scheme_Object *scheme_place(int argc, Scheme_Object *args[]) { Scheme_Place *place; Place_Start_Data *place_data; mz_proc_thread *proc_thread; Scheme_Object *collection_paths; mzrt_sema *ready; /* create place object */ place = MALLOC_ONE_TAGGED(Scheme_Place); place->so.type = scheme_place_type; mzrt_sema_create(&ready, 0); /* pass critical info to new place */ place_data = MALLOC_ONE(Place_Start_Data); place_data->ready = ready; if (argc == 2) { Scheme_Object *so; if (!scheme_is_module_path(args[0]) && !SCHEME_PATHP(args[0])) { scheme_wrong_type("place", "module-path or path", 0, argc, args); } if (!SCHEME_SYMBOLP(args[1])) { scheme_wrong_type("place", "symbol", 1, argc, args); } so = scheme_places_deep_copy_to_master(args[0]); place_data->module = so; so = scheme_places_deep_copy_to_master(args[1]); place_data->function = so; place_data->ready = ready; /* create channel */ { Scheme_Place_Bi_Channel *channel; channel = scheme_place_bi_channel_create(); place->channel = (Scheme_Object *) channel; channel = scheme_place_bi_peer_channel_create(channel); place_data->channel = (Scheme_Object *) channel; } } else { scheme_wrong_count_m("place", 2, 2, argc, args, 0); } collection_paths = scheme_current_library_collection_paths(0, NULL); collection_paths = scheme_places_deep_copy_to_master(collection_paths); place_data->current_library_collection_paths = collection_paths; /* create new place */ proc_thread = mz_proc_thread_create(place_start_proc, place_data); /* wait until the place has started and grabbed the value from `place_data'; it's important that a GC doesn't happen here until the other place is far enough. */ mzrt_sema_wait(ready); mzrt_sema_destroy(ready); place->proc_thread = proc_thread; return (Scheme_Object*) place; }