コード例 #1
0
ファイル: trashitem.c プロジェクト: GNOME/gvfs
void
trash_root_thaw (TrashRoot *root)
{
  NotifyClosure *closure;
  gboolean size_changed;
  int size;

  /* send notifications until we have none */
  while (TRUE)
    {
      g_rw_lock_writer_lock (&root->lock);
      if (g_queue_is_empty (root->notifications))
        break;

      closure = g_queue_pop_head (root->notifications);
      g_rw_lock_writer_unlock (&root->lock);

      trash_item_invoke_closure (closure);
    }

  /* still holding lock... */
  size = g_hash_table_size (root->item_table);
  size_changed = root->old_size != size;
  root->old_size = size;

  g_rw_lock_writer_unlock (&root->lock);

  if (size_changed)
    root->size_change (root->user_data);
}
コード例 #2
0
ファイル: rwlock.c プロジェクト: 01org/android-bluez-glib
static void
test_rwlock2 (void)
{
  static GRWLock lock;

  g_rw_lock_writer_lock (&lock);
  g_rw_lock_writer_unlock (&lock);
  g_rw_lock_writer_lock (&lock);
  g_rw_lock_writer_unlock (&lock);
}
コード例 #3
0
ファイル: rwlock.c プロジェクト: 01org/android-bluez-glib
static void
test_rwlock1 (void)
{
  GRWLock lock;

  g_rw_lock_init (&lock);
  g_rw_lock_writer_lock (&lock);
  g_rw_lock_writer_unlock (&lock);
  g_rw_lock_writer_lock (&lock);
  g_rw_lock_writer_unlock (&lock);
  g_rw_lock_clear (&lock);
}
コード例 #4
0
static void
gum_jsc_script_backend_unignore_later (GumScriptBackend * backend,
                                       GumThreadId thread_id)
{
  GumJscScriptBackend * self = GUM_JSC_SCRIPT_BACKEND (backend);
  GumJscScriptBackendPrivate * priv = self->priv;
  GMainContext * main_context;
  GSource * source;

  main_context = gum_script_scheduler_get_js_context (
      gum_jsc_script_backend_get_scheduler (self));

  gum_interceptor_ignore_current_thread (priv->interceptor);

  g_rw_lock_writer_lock (&priv->ignored_lock);

  priv->pending_unignores = g_slist_prepend (priv->pending_unignores,
      GSIZE_TO_POINTER (thread_id));
  source = priv->pending_timeout;
  priv->pending_timeout = NULL;

  g_rw_lock_writer_unlock (&priv->ignored_lock);

  if (source != NULL)
  {
    g_source_destroy (source);
    g_source_unref (source);
  }
  source = g_timeout_source_new_seconds (5);
  g_source_set_callback (source, gum_flush_pending_unignores, self, NULL);
  g_source_attach (source, main_context);

  g_rw_lock_writer_lock (&priv->ignored_lock);

  if (priv->pending_timeout == NULL)
  {
    priv->pending_timeout = source;
    source = NULL;
  }

  g_rw_lock_writer_unlock (&priv->ignored_lock);

  if (source != NULL)
  {
    g_source_destroy (source);
    g_source_unref (source);
  }

  gum_interceptor_unignore_current_thread (priv->interceptor);
}
コード例 #5
0
ファイル: freeqd.c プロジェクト: GooseYArd/freeq
int generation_table_merge(struct freeq_ctx *ctx, struct freeqd_state *fst, BIO *bio)
{
        struct freeq_table *tbl;
        struct freeq_table *curtbl;
        freeq_generation_t *gen = fst->current;
        int err;

        /* this needs to be moved outside this function */
        err = freeq_table_bio_read(ctx, &tbl, bio, gen->strings);
        if (err)
        {
                dbg(ctx, "unable to read tabledata\n");
                return err;
        }

        freeq_table_print(ctx, tbl, stdout);

        /* if we need to be able to replace node/tables in a
         * generation, another option would be to use a tree instead
         * of a linked list. Or we could store a pointer to the head
         * and tail of each senders segment of the list and remove
         * it */

        g_rw_lock_writer_lock(&(gen->rw_lock));
        curtbl = (struct freeq_table *)g_hash_table_lookup(gen->tables, tbl->name);
        if (curtbl != NULL)
        {
                dbg(ctx, "at least one host has sent %s for this generation\n", tbl->name);
                if (curtbl->senders != NULL && g_hash_table_contains(curtbl->senders, tbl->identity))
                {
                        /* we already put a table from this sender into this generation
                           what should we do?
                         */
                        dbg(ctx, "uh oh, we heard from this sender twice in a generation :(\n");
                }
                else
                {
                        /* merge the tables */
                        dbg(ctx, "would be merging tables here!\n");
                }
                g_rw_lock_writer_unlock(&(gen->rw_lock));
                return 1;
        }

        g_hash_table_insert(gen->tables, tbl->name, tbl);
        g_rw_lock_writer_unlock(&(gen->rw_lock));
        return FREEQ_OK;
}
コード例 #6
0
static gboolean
gum_flush_pending_unignores (gpointer user_data)
{
  GumJscScriptBackend * self = GUM_JSC_SCRIPT_BACKEND (user_data);
  GumJscScriptBackendPrivate * priv = self->priv;

  gum_interceptor_ignore_current_thread (priv->interceptor);

  g_rw_lock_writer_lock (&priv->ignored_lock);

  if (priv->pending_timeout == g_main_current_source ())
  {
    g_source_unref (priv->pending_timeout);
    priv->pending_timeout = NULL;
  }

  while (priv->pending_unignores != NULL)
  {
    GumThreadId thread_id;

    thread_id = GPOINTER_TO_SIZE (priv->pending_unignores->data);
    priv->pending_unignores = g_slist_delete_link (priv->pending_unignores,
        priv->pending_unignores);
    gum_jsc_script_backend_adjust_ignore_level_unlocked (self, thread_id, -1);
  }

  g_rw_lock_writer_unlock (&priv->ignored_lock);

  gum_interceptor_unignore_current_thread (priv->interceptor);

  return FALSE;
}
コード例 #7
0
ファイル: Light.c プロジェクト: RONNCC/pysoy
static void soy_bodies_light_finalize (GObject* obj) {
	soybodiesLight * self;
	soyscenesScene* _tmp0_;
	GeeHashSet* _tmp1_;
	gboolean _tmp2_ = FALSE;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SOY_BODIES_TYPE_LIGHT, soybodiesLight);
	_tmp0_ = ((soybodiesBody*) self)->scene;
	_tmp1_ = _tmp0_->lights;
	_tmp2_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp1_, self);
	if (_tmp2_) {
		soyscenesScene* _tmp3_;
		soyscenesScene* _tmp4_;
		GeeHashSet* _tmp5_;
		soyscenesScene* _tmp6_;
		_tmp3_ = ((soybodiesBody*) self)->scene;
		g_rw_lock_writer_lock (&_tmp3_->stepLock);
		_tmp4_ = ((soybodiesBody*) self)->scene;
		_tmp5_ = _tmp4_->lights;
		gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp5_, self);
		_tmp6_ = ((soybodiesBody*) self)->scene;
		g_rw_lock_writer_unlock (&_tmp6_->stepLock);
	}
	self->priv->_ambient = (g_free (self->priv->_ambient), NULL);
	self->priv->_diffuse = (g_free (self->priv->_diffuse), NULL);
	self->priv->_specular = (g_free (self->priv->_specular), NULL);
	_g_object_unref0 (self->priv->_texture);
	G_OBJECT_CLASS (soy_bodies_light_parent_class)->finalize (obj);
}
コード例 #8
0
ファイル: dispatcher.c プロジェクト: KnightKu/rnotify-c
static void publisher_updater(void *args, zctx_t *ctx, void *pipe){
	publishers_info *pub_interface = (struct publisher_list_struct*)args;
	void *publisher_updater_socket = create_socket(ctx, ZMQ_SUB, SOCK_CONNECT, DISPATCHER_NOTIFY_ADDR);
	zmq_setsockopt (publisher_updater_socket, ZMQ_SUBSCRIBE, "", strlen (""));
	while(true)
	{
		int size;
		char *publisher_addr = _recv_buff(publisher_updater_socket, &size);
		char *publisher_addr_dup  = to_c_string(publisher_addr, strlen(publisher_addr), strlen(publisher_addr)+1);

		hash_ring_add_node(pub_interface->publisher_ring, (uint8_t*)publisher_addr, strlen(publisher_addr));
		void *dispatch_socket = create_socket(ctx, ZMQ_PUB, SOCK_CONNECT, publisher_addr);
		g_rw_lock_writer_lock (&lock);

		g_hash_table_insert(pub_interface->publisher_socks, publisher_addr, dispatch_socket);

		GMutex m;
		g_mutex_init (&m);
		g_hash_table_insert(pub_interface->publisher_socks_locks, publisher_addr_dup, &m);

		g_rw_lock_writer_unlock (&lock);
		fprintf(stderr, "New Publisher was added at %s", publisher_addr);
		//free(publisher_addr);	
	}
}
コード例 #9
0
/**
 * free all entries of the pool
 *
 */
void network_connection_pool_free(network_connection_pool *pool) {
	if (!pool) return;

	g_hash_table_foreach_remove(pool->users, g_hash_table_true, NULL);

	g_mutex_lock(&(pool->connection_pool_mutex));
	g_hash_table_destroy(pool->users);
	g_mutex_unlock(&(pool->connection_pool_mutex));
	g_mutex_clear(&(pool->connection_pool_mutex));

	// added by sohu-inc.com
	g_rw_lock_writer_lock(&pool->pool_status_lock);
	g_hash_table_destroy(pool->conn_pool_status);
	g_rw_lock_writer_unlock(&pool->pool_status_lock);
	g_rw_lock_clear(&pool->pool_status_lock);
//	g_hash_table_destroy(pool->conn_num_in_use);
//	g_hash_table_destroy(pool->conn_pending);

	if (pool->garbage_connection_pool != NULL) {
		garbage_connection_pool_free(pool->garbage_connection_pool);
		pool->garbage_connection_pool = NULL;
	}

	g_free(pool);
}
コード例 #10
0
ファイル: drew.c プロジェクト: bk2204/drew
int drew_loader_load_plugin(DrewLoader *ldr, const char *plugin,
                            const char *path)
{
    int retval = 0, err = 0;
    library_t *lib;

    g_rw_lock_writer_lock(&ldr->lock);

    if (plugin && !path) {
        int npaths = drew_loader_get_search_path(ldr, 0, NULL), i;

        if (npaths < 0) {
            retval = npaths;
            goto out;
        }

        for (i = 0; i < npaths; i++) {
            drew_loader_get_search_path(ldr, i, &path);
            if (!load_library(ldr, plugin, path, &lib))
                break;
        }
        if (i == npaths) {
            retval = -DREW_ERR_RESOLUTION;
            goto out;
        }
    }
    else if ((err = load_library(ldr, plugin, path, &lib))) {
        retval = err;
        goto out;
    }
    retval = load_library_info(ldr, lib);
out:
    g_rw_lock_writer_unlock(&ldr->lock);
    return retval;
}
コード例 #11
0
ファイル: Hinge.c プロジェクト: frmdstryr/pysoy-ping-pong
static void _soy_joints_hinge_anchor_set (soyjointsHinge* self, soyatomsPosition* anchor) {
	struct dxJoint* _tmp0_;
	soyatomsPosition* _tmp1_;
	gfloat _tmp2_;
	gfloat _tmp3_;
	soyatomsPosition* _tmp4_;
	gfloat _tmp5_;
	gfloat _tmp6_;
	soyatomsPosition* _tmp7_;
	gfloat _tmp8_;
	gfloat _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (anchor != NULL);
	g_rw_lock_writer_lock (&soy_scenes__stepLock);
	_tmp0_ = ((soyjointsJoint*) self)->joint;
	_tmp1_ = anchor;
	_tmp2_ = soy_atoms_position_get_x (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = anchor;
	_tmp5_ = soy_atoms_position_get_y (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = anchor;
	_tmp8_ = soy_atoms_position_get_z (_tmp7_);
	_tmp9_ = _tmp8_;
	dJointSetHingeAnchor ((struct dxJoint*) _tmp0_, (dReal) _tmp3_, (dReal) _tmp6_, (dReal) _tmp9_);
	g_rw_lock_writer_unlock (&soy_scenes__stepLock);
}
コード例 #12
0
/**
 * 获取对应规则的动作
 * @param table 最里层sql队则列表
 * @param normalized_sql 标准化的sql
 * @param exist[in&&out] 用于标识规则是否存在
 * @return
 */
security_action get_action_from_sql_rule(
		sql_rule_table *table,
		const char *normalized_sql,
		int *exist
		) {
	g_assert(exist);
	*exist = 0;
	security_action ret = ACTION_SAFE;
	if (NULL == table || NULL == normalized_sql) {
			return ret;
	}

	sql_security_rule *rule = NULL;
	GString *sql_key = g_string_new(normalized_sql);
	g_rw_lock_writer_lock(&table->table_lock);
	rule = g_hash_table_lookup(table->sql_rule, sql_key);
	if (rule && !rule->is_disabled) {
		ret = rule->action;
		*exist = 1;
	}
	g_rw_lock_writer_unlock(&table->table_lock);

	g_string_free(sql_key, TRUE);

	return ret;
}
コード例 #13
0
ファイル: Hinge.c プロジェクト: frmdstryr/pysoy-ping-pong
static void _soy_joints_hinge_axis_set (soyjointsHinge* self, soyatomsAxis* value) {
	soyatomsAxis* _tmp0_;
	soyatomsAxis* _tmp1_;
	soyatomsAxis* axis;
	struct dxJoint* _tmp2_;
	gfloat _tmp3_;
	gfloat _tmp4_;
	gfloat _tmp5_;
	gfloat _tmp6_;
	gfloat _tmp7_;
	gfloat _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = value;
	_tmp1_ = soy_atoms_axis_new_normalize (_tmp0_);
	axis = _tmp1_;
	g_rw_lock_writer_lock (&soy_scenes__stepLock);
	_tmp2_ = ((soyjointsJoint*) self)->joint;
	_tmp3_ = soy_atoms_axis_get_x (axis);
	_tmp4_ = _tmp3_;
	_tmp5_ = soy_atoms_axis_get_y (axis);
	_tmp6_ = _tmp5_;
	_tmp7_ = soy_atoms_axis_get_z (axis);
	_tmp8_ = _tmp7_;
	dJointSetHingeAxis ((struct dxJoint*) _tmp2_, (dReal) _tmp4_, (dReal) _tmp6_, (dReal) _tmp8_);
	g_rw_lock_writer_unlock (&soy_scenes__stepLock);
	_g_object_unref0 (axis);
}
コード例 #14
0
ファイル: rwlock.c プロジェクト: 01org/android-bluez-glib
static void
acquire (gint nr)
{
  GThread *self;

  self = g_thread_self ();

  if (!g_rw_lock_writer_trylock (&locks[nr]))
    {
      if (g_test_verbose ())
        g_print ("thread %p going to block on lock %d\n", self, nr);

      g_rw_lock_writer_lock (&locks[nr]);
    }

  g_assert (owners[nr] == NULL);   /* hopefully nobody else is here */
  owners[nr] = self;

  /* let some other threads try to ruin our day */
  g_thread_yield ();
  g_thread_yield ();
  g_thread_yield ();

  g_assert (owners[nr] == self);   /* hopefully this is still us... */
  owners[nr] = NULL;               /* make way for the next guy */

  g_rw_lock_writer_unlock (&locks[nr]);
}
コード例 #15
0
/**
 * 向db-sql-rule的列表中插入规则
 * @param table db-sql-rule规则列表
 * @param dbname 规则对应的数据库名
 * @param normalized_sql 标准化sql
 * @param action 规则对应的动作
 * @param is_disabled 规则对应的开关
 * @return 新建的db-sql-rule变量
 */
sql_security_rule* insert_rule_to_db_sql_rule(
		db_sql_rule_table *table,
		const char *dbname,
		const char *normalized_sql,
		security_action action,
		gboolean is_disabled) {
	if (NULL == table) {
		return NULL;
	}
	if (NULL == dbname || NULL == normalized_sql) {
		return NULL;
	}

	GString *db_key = g_string_new(dbname);
	sql_security_rule* rule = NULL;
	sql_rule_table* sql_rule_table_v = NULL;
	g_rw_lock_writer_lock(&table->table_lock);
	sql_rule_table_v = g_hash_table_lookup(table->db_sql_rule, db_key);
	if (NULL == sql_rule_table_v) {
		sql_rule_table_v = sql_rule_table_new();
		GString *db_key_used = g_string_new(dbname);
		g_hash_table_insert(table->db_sql_rule, db_key_used, sql_rule_table_v);
	}
	g_rw_lock_writer_unlock(&table->table_lock);
	rule = insert_rule_to_sql_rule(
			sql_rule_table_v,
			normalized_sql,
			action,
			is_disabled
			);

	g_string_free(db_key, TRUE);
	return rule;
}
コード例 #16
0
ファイル: meta0_backend.c プロジェクト: dibaggioj/oio-sds
static GError *
_reload(struct meta0_backend_s *m0, gboolean lazy)
{
	GError *err = NULL;

	EXTRA_ASSERT(m0 != NULL);
	GRID_TRACE("%s(%p,lazy=%d)", __FUNCTION__, m0, lazy);

	g_rw_lock_writer_lock(&(m0->rwlock));

	if (!lazy || m0->reload_requested || !m0->array_by_prefix || !m0->array_meta1_ref) {
		if (m0->array_by_prefix) {
			meta0_utils_array_clean(m0->array_by_prefix);
			m0->array_by_prefix = NULL;
		}
		if (m0->array_meta1_ref) {
			meta0_utils_array_meta1ref_clean(m0->array_meta1_ref);
			m0->array_meta1_ref = NULL;
		}

		err = _load(m0);
		m0->reload_requested = FALSE;
		if (NULL != err)
			g_prefix_error(&err, "Loading error: ");
	}

	g_rw_lock_writer_unlock(&(m0->rwlock));
	return err;
}
コード例 #17
0
ファイル: Universal.c プロジェクト: RONNCC/pysoy
static void _soy_joints_universal_anchor_set (soyjointsUniversal* self, soyatomsPosition* anchor) {
	soyscenesScene* _tmp0_;
	struct dxJoint* _tmp1_;
	soyatomsPosition* _tmp2_;
	gfloat _tmp3_;
	gfloat _tmp4_;
	soyatomsPosition* _tmp5_;
	gfloat _tmp6_;
	gfloat _tmp7_;
	soyatomsPosition* _tmp8_;
	gfloat _tmp9_;
	gfloat _tmp10_;
	soyscenesScene* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (anchor != NULL);
	_tmp0_ = ((soyjointsJoint*) self)->scene;
	g_rw_lock_writer_lock (&_tmp0_->stepLock);
	_tmp1_ = ((soyjointsJoint*) self)->joint;
	_tmp2_ = anchor;
	_tmp3_ = soy_atoms_position_get_x (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = anchor;
	_tmp6_ = soy_atoms_position_get_y (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = anchor;
	_tmp9_ = soy_atoms_position_get_z (_tmp8_);
	_tmp10_ = _tmp9_;
	dJointSetUniversalAnchor ((struct dxJoint*) _tmp1_, (dReal) _tmp4_, (dReal) _tmp7_, (dReal) _tmp10_);
	_tmp11_ = ((soyjointsJoint*) self)->scene;
	g_rw_lock_writer_unlock (&_tmp11_->stepLock);
}
コード例 #18
0
ファイル: Universal.c プロジェクト: RONNCC/pysoy
static void _soy_joints_universal_axis2_set (soyjointsUniversal* self, soyatomsAxis* value) {
	soyatomsAxis* _tmp0_;
	soyatomsAxis* _tmp1_;
	soyatomsAxis* axis2;
	soyscenesScene* _tmp2_;
	struct dxJoint* _tmp3_;
	gfloat _tmp4_;
	gfloat _tmp5_;
	gfloat _tmp6_;
	gfloat _tmp7_;
	gfloat _tmp8_;
	gfloat _tmp9_;
	soyscenesScene* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (value != NULL);
	_tmp0_ = value;
	_tmp1_ = soy_atoms_axis_new_normalize (_tmp0_);
	axis2 = _tmp1_;
	_tmp2_ = ((soyjointsJoint*) self)->scene;
	g_rw_lock_writer_lock (&_tmp2_->stepLock);
	_tmp3_ = ((soyjointsJoint*) self)->joint;
	_tmp4_ = soy_atoms_axis_get_x (axis2);
	_tmp5_ = _tmp4_;
	_tmp6_ = soy_atoms_axis_get_y (axis2);
	_tmp7_ = _tmp6_;
	_tmp8_ = soy_atoms_axis_get_z (axis2);
	_tmp9_ = _tmp8_;
	dJointSetUniversalAxis2 ((struct dxJoint*) _tmp3_, (dReal) _tmp5_, (dReal) _tmp7_, (dReal) _tmp9_);
	_tmp10_ = ((soyjointsJoint*) self)->scene;
	g_rw_lock_writer_unlock (&_tmp10_->stepLock);
	_g_object_unref0 (axis2);
}
コード例 #19
0
ファイル: gstmeta.c プロジェクト: PeterXu/gst-mobile
const GstMetaInfo *
gst_meta_register (GType api, const gchar * impl, gsize size,
    GstMetaInitFunction init_func, GstMetaFreeFunction free_func,
    GstMetaTransformFunction transform_func)
{
  GstMetaInfo *info;

  g_return_val_if_fail (api != 0, NULL);
  g_return_val_if_fail (impl != NULL, NULL);
  g_return_val_if_fail (size != 0, NULL);

  info = g_slice_new (GstMetaInfo);
  info->api = api;
  info->type = g_pointer_type_register_static (impl);
  info->size = size;
  info->init_func = init_func;
  info->free_func = free_func;
  info->transform_func = transform_func;

  GST_CAT_DEBUG (GST_CAT_META,
      "register \"%s\" implementing \"%s\" of size %" G_GSIZE_FORMAT, impl,
      g_type_name (api), size);

  g_rw_lock_writer_lock (&lock);
  g_hash_table_insert (metainfo, (gpointer) impl, (gpointer) info);
  g_rw_lock_writer_unlock (&lock);

  return info;
}
コード例 #20
0
ファイル: gresource.c プロジェクト: 492852238/SourceLearning
/**
 * g_resources_unregister:
 * @resource: A #GResource
 *
 * Unregisters the resource from the process-global set of resources.
 *
 * Since: 2.32
 **/
void
g_resources_unregister (GResource *resource)
{
  g_rw_lock_writer_lock (&resources_lock);
  g_resources_unregister_unlocked (resource);
  g_rw_lock_writer_unlock (&resources_lock);
}
コード例 #21
0
ファイル: view.c プロジェクト: coinorama/coinorama
/*
 * view_append_single_data
 */
void
view_append_single_data ( view *v,
                          gdouble *data )
{
  vblock *vb;
  guint i;

  g_rw_lock_writer_lock ( &(v->lock) );

  if ( (data[STORE_COLUMN_TIMESTAMP] - v->most_recent_entry) <= v->precision )
    {
      for ( i=0; i<v->store->nb_cols; ++i )
        v->current_line[i] += data[i];

      /* todo: add update of view additional columns */

      v->current_nb_values++;
    }
  else
    {
      if ( v->most_recent_entry > 0 )
        {
          for ( i=0; i<v->store->nb_cols; ++i )
            v->current_line[i] = v->current_line[i] / v->current_nb_values;

          /* todo: add update of view additional columns */

          if ( vblock_is_full(v->blocks_tail) )
            {
              vb = vblock_new ( v->nb_cols );
              v->blocks_tail->next_block = vb;
              vb->prev_block = v->blocks_tail;
              v->blocks_tail = vb;
#ifndef _WITHOUT_PRUNING
              /* we always have at least two vblocks when reaching this point */
              v->blocks_head = vblocks_prune ( v->blocks_head, v->current_line[VIEW_COLUMN_TIMESTAMP]-(v->length+1) );
              /* after that, v->current_line will be pushed ; thus it will always contain at least one line of data */
#endif
            }

          vblock_append ( v->blocks_tail, v->current_line );
          v->nb_entries++;
        }

      /* and store new data in a fresh line */
      for ( i=0; i<v->store->nb_cols; ++i )
        v->current_line[i] = data[i];

      /* todo: add update of view additional columns */

      v->current_nb_values = 1;
      v->most_recent_entry = data[STORE_COLUMN_TIMESTAMP];
    }

  for ( i=0; i<v->nb_cols; ++i )
    v->current_line_most_recent_data[i] = v->current_line[i] / v->current_nb_values;

  g_rw_lock_writer_unlock ( &(v->lock) );
}
コード例 #22
0
ファイル: fu-mutex.c プロジェクト: vathpela/fwupd
/**
 * fu_mutex_unlock:
 * @self: a #FuMutex
 *
 * Release a read or write lock.
 *
 * Since: 1.1.2
 **/
void
fu_mutex_unlock (FuMutex *self, FuMutexAccess kind)
{
	if (kind == FU_MUTEX_ACCESS_READ)
		g_rw_lock_reader_unlock (&self->rw_lock);
	else if (kind == FU_MUTEX_ACCESS_WRITE)
		g_rw_lock_writer_unlock (&self->rw_lock);
}
コード例 #23
0
/*
 * refstore_append_single_data
 */
void
refstore_append_single_data ( refstore *rs,
                              gdouble *data )
{
  g_rw_lock_writer_lock ( &(rs->lock) );
  memcpy ( rs->most_recent_data, data, sizeof(gdouble)*STORE_BLOCK_COLS );
  rs->nb_entries++;
  g_rw_lock_writer_unlock ( &(rs->lock) );
}
コード例 #24
0
void chassis_event_remove_connection(chassis *chas, network_mysqld_con *client_con) {
    chassis_event_thread_t* thread = g_ptr_array_index(chas->threads, cur_thid);

    g_assert(client_con != NULL);

    g_rw_lock_writer_lock(&thread->connection_lock);
    thread->connection_list = g_list_remove(thread->connection_list, client_con);
    thread->connection_nums--;
    g_rw_lock_writer_unlock(&thread->connection_lock);
}
コード例 #25
0
/**
 * @author sohu-inc.com
 * 向连接池统计hashtable中插入一个新的记录
 *
 */
void insert_conn_pool_status(network_connection_pool *pool, gchar *username, pool_status *value) {
	g_assert(pool);
	g_assert(username);
	g_assert(value);
	
	gchar *key = g_strdup(username);
	g_rw_lock_writer_lock (&pool->pool_status_lock);
	g_hash_table_insert(pool->conn_pool_status, key, value);
	g_rw_lock_writer_unlock (&pool->pool_status_lock);
}
コード例 #26
0
slow_query_log_config_t *slow_query_log_config_t_new(void) {
	slow_query_log_config_t *config = NULL;
	config = g_new0(slow_query_log_config_t, 1);
	if (config != NULL) {
		g_rw_lock_init ( &(config->rwlock) );
		g_rw_lock_writer_lock ( &(config->rwlock) );
		config->is_enabled = FALSE;
		config->log_file = slow_query_log_file_t_new();
		config->filter = slow_query_log_filter_t_new();
		if (config->log_file == NULL || config->filter == NULL) {
			g_rw_lock_writer_unlock ( &(config->rwlock) );
			slow_query_log_config_t_free(config);
			config = NULL;
		} else {
			g_rw_lock_writer_unlock ( &(config->rwlock) );
		}
	}
	return config;
}
コード例 #27
0
ファイル: metacd_http.c プロジェクト: saakaifoundry/oio-sds
static guint
_lru_tree_expire (GRWLock *rw, struct lru_tree_s *lru, const gint64 delay)
{
	if (delay <= 0) return 0;
	const gint64 now = oio_ext_monotonic_time();
	g_rw_lock_writer_lock (rw);
	guint count = lru_tree_remove_older (lru, OLDEST(now,delay));
	g_rw_lock_writer_unlock (rw);
	return count;
}
コード例 #28
0
ファイル: gresource.c プロジェクト: 492852238/SourceLearning
static void
register_lazy_static_resources (void)
{
  if (g_atomic_pointer_get (&lazy_register_resources) == NULL)
    return;

  g_rw_lock_writer_lock (&resources_lock);
  register_lazy_static_resources_unlocked ();
  g_rw_lock_writer_unlock (&resources_lock);
}
コード例 #29
0
ファイル: dupin_attachment_db.c プロジェクト: dplatform/dupin
gboolean
dupin_attachment_db_delete (DupinAttachmentDB * attachment_db, GError ** error)
{
  g_return_val_if_fail (attachment_db != NULL, FALSE);

  g_rw_lock_writer_lock (attachment_db->rwlock);
  attachment_db->todelete = TRUE;
  g_rw_lock_writer_unlock (attachment_db->rwlock);

  return TRUE;
}
コード例 #30
0
ファイル: dupin_attachment_db.c プロジェクト: dplatform/dupin
void
dupin_attachment_db_unref (DupinAttachmentDB * attachment_db)
{
  Dupin *d;

  g_return_if_fail (attachment_db != NULL);

  d = attachment_db->d;

  g_rw_lock_writer_lock (attachment_db->rwlock);

  if (attachment_db->ref > 0)
    {
      attachment_db->ref--;

#if DEBUG
      fprintf(stderr,"dupin_attachment_db_unref: (%p) name=%s \t ref--=%d\n", g_thread_self (), attachment_db->name, (gint) attachment_db->ref);
#endif
    }

  g_rw_lock_writer_unlock (attachment_db->rwlock);

  if (attachment_db->todelete == TRUE)
    {
      if (attachment_db->ref > 0)
        {
          g_warning ("dupin_attachment_db_unref: (thread=%p) attachment database %s flagged for deletion but can't free it due ref is %d\n", g_thread_self (), attachment_db->name, (gint) attachment_db->ref);
        }
      else
        {
	  if (dupin_attachment_db_p_update (attachment_db, NULL) == FALSE)
            {
              g_warning("dupin_attachment_db_unref: could not remove reference from parent for attachment db '%s'\n", attachment_db->name);
            }

          g_rw_lock_writer_lock (d->rwlock);
          g_hash_table_remove (d->attachment_dbs, attachment_db->name);
          g_rw_lock_writer_unlock (d->rwlock);
        }
    }
}