The bson_context_t structure is context for generation of BSON Object IDs. This context allows for specialized overriding of how ObjectIDs are generated based on the applications requirements. For example, disabling of PID caching can be configured if the application cannot detect when a call to fork() has occurred.

#include<bson.h>intmain(intargc,char*argv[]){bson_context_t*ctx=NULL;bson_oid_toid;/* use default context, via bson_context_get_default() */bson_oid_init(&oid,NULL);/* specify a local context for additional control */ctx=bson_context_new(BSON_CONTEXT_DISABLE_PID_CACHE|BSON_CONTEXT_THREAD_SAFE);bson_oid_init(&oid,ctx);bson_context_destroy(ctx);return0;}