Next: 4.10.10 nxn Up: 4.10 Classes Previous: 4.10.8 nx Contents Index
Subsections

- 4.10.9.1 API

##
4.10.9 nxa

The nxa class implements garbage collection. The garbage collector runs a separate thread that is controlled via an asynchronous message queue. The collector thread is only responsible for doing asynchronous collection due to allocation inactivity and all sweeping; all other marking is synchronously done in the thread context of the mutator that triggers collection.

### 4.10.9.1 API

void * nxa_malloc_e(cw_nxa_t *a_nxa, size_t a_size, const char *a_filename, cw_uint32_t a_line_num):

void * nxa_malloc(cw_nxa_t *a_nxa, size_t a_size):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_size:
      Size of memory range to allocate.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    retval:
      Pointer to a memory range.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    malloc() wrapper.

void * nxa_realloc_e(cw_nxa_t *a_nxa, size_t a_size, size_t a_old_size, const char *a_filename, cw_uint32_t a_line_num):

void * nxa_realloc(cw_nxa_t *a_nxa, size_t a_size):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_ptr:
      Pointer to memory range to be reallocated.
    a_size:
      Size of memory range to allocate.
    a_old_size:
      Size of memory range previously pointed to by a_ptr.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    retval:
      Pointer to a memory range.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    realloc() wrapper.

void * nxa_free_e(cw_nxa_t *a_nxa, void *a_ptr, size_t a_size, const char *a_filename, cw_uint32_t a_line_num):

void * nxa_free(cw_nxa_t *a_nxa, void *a_ptr, size_t a_size):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_ptr:
      Pointer to to memory range to be freed.
    a_size:
      Sizef of memory range pointed to by a_ptr.
    a_filename:
      Should be __FILE__.
    a_line_num:
      Should be __LINE__.
  Output(s):
    None.
  Exception(s):
    None.
  Description:
    free() wrapper.

void nxa_collect(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Do a synchronous garbage collection.

void nxa_dump(cw_nxa_t *a_nxa, cw_nxo_t *a_thread):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_thread:
      Pointer to a thread nxo.
  Output(s):
    Output printed to stdout .
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Print the internal state of gcdict to stdout .

cw_bool_t nxa_active_get(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    retval:
      FALSE:
        Garbage collector deactivated.
      TRUE:
        Garbage collector active.
  Exception(s):
    None.
  Description:
    Return whether the garbage collector is active (runnable).

void nxa_active_set(cw_nxa_t *a_nxa, cw_bool_t a_active):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_active:
      FALSE:
        Deactivate garbage collector.
      TRUE:
        Activate garbage collector.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Send a message to the garbage collector to activate or deactivate. The asynchronous nature of the message means that it is possible for the garbage collector to run after this function returns, even if a deactivation message has been sent.

cw_nxoi_t nxa_period_get(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    retval:
      Current inactivity period in seconds that the garbage collector waits before doing a collection.
  Exception(s):
    None.
  Description:
    Return the current inactivity period in seconds that the garbage collector waits before doing a collection.

void nxa_period_set(cw_nxa_t *a_nxa, cw_nxoi_t a_period):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_period:
      Inactivity period in seconds that the garbage collector should wait before doing a collection. If 0, the garbage collector will never run due to inactivity.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Set the inactivity period in seconds that the garbage collector should wait before doing a collection.

cw_nxoi_t nxa_threshold_get(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    retval:
      Number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.
  Exception(s):
    None.
  Description:
    Return the number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.

void nxa_threshold_set(cw_nxa_t *a_nxa, cw_nxoi_t a_threshold):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    a_threshold:
      The number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.
  Output(s):
    None.
  Exception(s):
    CW_ONYXX_OOM.
  Description:
    Set the number of bytes of memory allocated since the last garbage collection that will trigger the garbage collector to run.

void nxa_stats_get(cw_nxa_t *a_nxa, cw_nxoi_t *r_collections, cw_nxoi_t *r_count, cw_nxoi_t *r_ccount, cw_nxoi_t *r_cmark, cw_nxoi_t *r_csweep, cw_nxoi_t *r_mcount, cw_nxoi_t *r_mmark, cw_nxoi_t *r_msweep, cw_nxoi_t *r_scount, cw_nxoi_t *r_smark, cw_nxoi_t *r_ssweep):

  Input(s):
    a_nxa:
      Pointer to a nxa.
    r_collections:
      Pointer to an integer.
    r_count:
      Pointer to an integer.
    r_ccount:
      Pointer to an integer.
    r_cmark:
      Pointer to an integer.
    r_csweep:
      Pointer to an integer.
    r_mcount:
      Pointer to an integer.
    r_mmark:
      Pointer to an integer.
    r_msweep:
      Pointer to an integer.
    r_scount:
      Pointer to an integer.
    r_smark:
      Pointer to an integer.
    r_ssweep:
      Pointer to an integer.
  Output(s):
    *r_collections:
      Number of times the garbage collector has run.
    *r_count:
      Current number of bytes of memory allocated.
    *r_ccount:
      Number of bytes of memory allocated as of the end of the most recent garbage collection.
    *r_cmark:
      Number of microseconds spent in the mark phase of the most recent garbage collection.
    *r_csweep:
      Number of microseconts spent in the sweep phase of the most recent garbage collection.
    *r_mcount:
      Largest number of bytes of memory ever allocated at any point in time.
    *r_mmark:
      Largest number of microseconds ever spent in the mark phase of a garbage collection.
    *r_msweep:
      Largest number of microseconts spent in the sweep phase of a garbage collection.
    *r_scount:
      Total number of bytes of memory ever allocated.
    *r_smark:
      Total number of microseconds spent in the mark phase of all garbage collections.
    *r_ssweep:
      Total number of microseconts spent in the sweep phase of all garbage collections.
  Exception(s):
    None.
  Description:
    Return garbage collector statistics.

cw_nx_t * nxa_nx_get(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    retval:
      Pointer to a nx.
  Exception(s):
    None.
  Description:
    Return a pointer to the nx associated with a_nxa.

cw_nxo_t * nxa_gcdict_get(cw_nxa_t *a_nxa):

  Input(s):
    a_nxa:
      Pointer to a nxa.
  Output(s):
    retval:
      Pointer to a dict nxo.
  Exception(s):
    None.
  Description:
    Return a pointer to the dict nxo corresponding to gcdict .

Next: 4.10.10 nxn Up: 4.10 Classes Previous: 4.10.8 nx Contents Index