OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SchemeEval.cc File Reference
#include <unistd.h>
#include <fcntl.h>
#include <cstddef>
#include <libguile.h>
#include <libguile/backtrace.h>
#include <libguile/debug.h>
#include <libguile/lang.h>
#include <pthread.h>
#include <opencog/util/Logger.h>
#include <opencog/util/oc_assert.h>
#include <opencog/util/platform.h>
#include <opencog/atomspace/TruthValue.h>
#include "SchemeEval.h"
#include "SchemePrimitive.h"
#include "SchemeSmob.h"
+ Include dependency graph for SchemeEval.cc:

Go to the source code of this file.

Macros

#define WORK_AROUND_GUILE_185_BUG
 
#define WORK_AROUND_GUILE_THREADING_BUG
 
#define BUFSZ   1000
 

Functions

static void * do_bogus_scm (void *p)
 
static void init_only_once (void)
 
static void do_gc (void)
 
SCM recast_scm_eval_string (void *expr)
 
static SCM thunk_scm_eval (void *expr)
 
static SchemeEvalget_from_pool (void)
 
static void return_to_pool (SchemeEval *ev)
 

Variables

std::mutex init_mtx
 
static std::atomic_flag eval_is_inited = ATOMIC_FLAG_INIT
 
static thread_local bool thread_is_inited = false
 
static SCM guile_user_module
 
static pthread_mutex_t serialize_lock
 
static pthread_key_t ser_key = 0
 
static concurrent_stack
< SchemeEval * > 
pool
 
static std::mutex pool_mtx
 

Macro Definition Documentation

#define BUFSZ   1000
#define WORK_AROUND_GUILE_185_BUG

Definition at line 208 of file SchemeEval.cc.

#define WORK_AROUND_GUILE_THREADING_BUG

Definition at line 230 of file SchemeEval.cc.

Function Documentation

static void* do_bogus_scm ( void *  p)
static

Definition at line 222 of file SchemeEval.cc.

+ Here is the caller graph for this function:

static void do_gc ( void  )
static

Ad hoc hack to try to limit guile memory consumption, while still providing decent performance. The problem addressed here is that guile can get piggy with the system RAM, happily gobbling up RAM instead of garbage-collecting it. Users have noticed. See github issue #1116. This improves on the original pull request #1117. Clue: bug report #1419 suggests the problem is related to the do_async_output flag– setting it to false avoids the blow-up. Is there an i/o-related leak or weird reserve bug?

Definition at line 551 of file SchemeEval.cc.

+ Here is the caller graph for this function:

static SchemeEval* get_from_pool ( void  )
static

Definition at line 1108 of file SchemeEval.cc.

References pool, and pool_mtx.

+ Here is the caller graph for this function:

static void init_only_once ( void  )
static

Definition at line 260 of file SchemeEval.cc.

References do_bogus_scm(), eval_is_inited, guile_user_module, ser_key, and serialize_lock.

+ Here is the caller graph for this function:

SCM recast_scm_eval_string ( void *  expr)

Definition at line 848 of file SchemeEval.cc.

+ Here is the caller graph for this function:

static void return_to_pool ( SchemeEval ev)
static

Definition at line 1116 of file SchemeEval.cc.

References pool, and pool_mtx.

+ Here is the caller graph for this function:

static SCM thunk_scm_eval ( void *  expr)
static

Definition at line 1014 of file SchemeEval.cc.

+ Here is the caller graph for this function:

Variable Documentation

std::atomic_flag eval_is_inited = ATOMIC_FLAG_INIT
static

Definition at line 204 of file SchemeEval.cc.

SCM guile_user_module
static

Definition at line 220 of file SchemeEval.cc.

std::mutex init_mtx

Definition at line 35 of file SchemeEval.cc.

concurrent_stack<SchemeEval*> pool
static

Definition at line 1105 of file SchemeEval.cc.

std::mutex pool_mtx
static

Definition at line 1106 of file SchemeEval.cc.

pthread_key_t ser_key = 0
static

Definition at line 255 of file SchemeEval.cc.

pthread_mutex_t serialize_lock
static

Definition at line 254 of file SchemeEval.cc.

thread_local bool thread_is_inited = false
static

Definition at line 205 of file SchemeEval.cc.