In TS, is it important to favor use of continuation mutexes to avoid
thread blocking.  For example, should code like this:

before();
TSMutexLock(mutex);
critical_section();
TSMutexUnlock(mutex);
after();

be replaced with code like:

int contf_after(TSCont, TSEvent, void *)
{
  after();

  return 0;
}

int contf_critical_section(TSCont, TSEvent, void *)
{
  critical_section();

  static TSCont cont_after = TSContCreate(contf_after, nullptr);

  TSContSchedule(cont_after, 0, TS_THREAD_POOL_DEFAULT);

  return 0;
}

// ...

before();

static TSCont cont_critical_section =
TSContCreate(contf_critical_section, mutex);

TSContSchedule(cont_critical_section, 0, TS_THREAD_POOL_DEFAULT);

// ...

(This is plugin code but I assume the same principle would apply to core code.)

Reply via email to