コード例 #1
0
    void wait() {
      if(!pending()) return;
      mark_wait(true);
      try {
	m_coro_impl->wait(1);
	BOOST_ASSERT(!pending());
      } catch (...) {
	mark_wait(false);
	throw;
      }
      mark_wait(false);
    }
コード例 #2
0
static void* messageHandler(void *arg) {
    MessageHeader *header = (MessageHeader*)arg;
    printf("Start Message Handler: %s!\n", header->tag);

    while (1) {
        pending();
        printf("waitting!\n");
        test(header->fd);
        Message *msg = popupMessage(header, 0);
        if (NULL != msg) {
            fire(header->cb, (void*)msg);
        }
        /*
        pthread_mutex_lock(&(header->mutex));
        if (p->next == NULL) {
            printf("Empty Message Queue...\n");
        } else {
            printf("yuzhou debug\n");
            p->next = q->next;
            //应该增加一个线程通知
            //popupMessage();
            
            fire(cb, (void*)q);
            //cb((void*)q);
        }
        pthread_mutex_unlock(&(header->mutex));
         */
    }

    return NULL;
}
コード例 #3
0
ファイル: build_log.cpp プロジェクト: daniperez/magrit
std::string
colorize_linux ( const std::string& status, bool color )
{
  std::stringstream output;

  for ( size_t i = 0 ; i < status.size() ; ++i )
  {
    switch ( status[i] )
    {
      case 'O':
        output << cool ( status[i], color );
        break;
      case 'E':
        output << error ( status[i], color );
        break;
      case 'R':
        output << running ( status[i], color );
        break;
      case 'P':
        output << pending ( status[i], color );
        break;
      case '?':
        output << warning ( status[i], color );
        break;
      default:
        output << status[i];
        break;
    }
  }

  return output.str();
}
void test_that_pends() {
	void* pointer = (void*) 0x1;
	/* Asks dojo_unit to hold this tests execution but counts it */
	pending();
	/* Only verifies if point != NULL (or == NULL if assert_null) */
	assert_not_null("0x1 should not be NULL", pointer);
}
コード例 #5
0
void CompilationEnvironment::use_dylib( const String &cpp ) {
    BasicVec<String> pending( cpp );
    set_comp_dir( directory_of( cpp ) + "/compilations" );

    while ( pending.size() ) {
        String fpp = pending.back();
        pending.pop_back();

        parsed.push_back_unique( absolute_filename( fpp ) );

        CompilationCppParser cpp_parser( *this, fpp, dep_for( fpp ) );

        // .h -> .cpp or .cu ?
        for( int i = 0; i < cpp_parser.inc_files.size(); ++i ) {
            String h = absolute_filename( cpp_parser.inc_files[ i ] );
            if ( h.ends_with( ".h" ) ) {
                String base = h.beg_upto( h.size() - 2 );
                if ( file_exists( base + ".cpp" ) and not parsed.contains( base + ".cpp" ) ) pending.push_back_unique( base + ".cpp" );
                if ( file_exists( base + ".cu"  ) and not parsed.contains( base + ".cu"  ) ) pending.push_back_unique( base + ".cu"  );
            }
        }
    }

    dylibs << lib_for( cpp, true );
}
コード例 #6
0
static void
fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc)
{
	struct fd_resource *rsc = fd_resource(prsc);

	if (pending(rsc, FD_PENDING_WRITE | FD_PENDING_READ))
		fd_context_render(pctx);
}
コード例 #7
0
 void delegate(T& x) {
   auto rp = self_->make_response_promise();
   if (! rp.pending()) {
     CAF_LOG_DEBUG("suppress response message: invalid response promise");
     return;
   }
   deliver(rp, x);
 }
コード例 #8
0
    void assign(const T& val) {
      BOOST_ASSERT(pending());
      context_pointer p = m_coro_impl;
      m_coro_impl = 0;
      m_optional = val;
      p->count_down();
      if(waited() && p->signal())
	p->wake_up();
    }
コード例 #9
0
ファイル: sig.cpp プロジェクト: gdonoso/socketxx
bool sig::ispending (int signo) const
{
  sigset_t s = pending ();
  switch (sigismember (&s, signo)) {
  case 0: return false;
  case 1: return true;
  }
  throw sigerr();
}
コード例 #10
0
GstState GetState(GstElement * inElement)
{
    GstState state(GST_STATE_VOID_PENDING), pending(GST_STATE_VOID_PENDING);
    GstStateChangeReturn ret = gst_element_get_state(inElement, &state, &pending, 1000*1000*1000);
    if (GST_STATE_CHANGE_FAILURE == ret)
    {
        throw std::runtime_error("Failed to obtain the pipeline state. ");
    }
    return state;
}
コード例 #11
0
ファイル: streams.c プロジェクト: Alkzndr/freebsd
/* Implements ra_svn_pending_fn_t */
static svn_boolean_t
file_pending_cb(void *baton)
{
  file_baton_t *b = baton;
  apr_pollfd_t pfd;

  pfd.desc_type = APR_POLL_FILE;
  pfd.desc.f = b->in_file;

  return pending(&pfd, b->pool);
}
コード例 #12
0
ファイル: streams.c プロジェクト: Alkzndr/freebsd
/* Implements ra_svn_pending_fn_t */
static svn_boolean_t
sock_pending_cb(void *baton)
{
  sock_baton_t *b = baton;
  apr_pollfd_t pfd;

  pfd.desc_type = APR_POLL_SOCKET;
  pfd.desc.s = b->sock;

  return pending(&pfd, b->pool);
}
コード例 #13
0
//##############################################################################
//##############################################################################
uint64_t
BerkeleyDBCXXDb::version() const
{
    RANGE_LOG_FUNCTION();
    ChangeList changes = this->read_changelist();
    uint64_t version = changes.current_version();
    auto txn = current_txn_.lock();
    if(txn && txn->pending() > 0) {
        ++version;
    }
    return version;
}
コード例 #14
0
ファイル: mwait.c プロジェクト: SANL-2015/SANL-2015
static void* do_liblock_execute_operation(mwait)(liblock_lock_t* lock, void* (*pending)(void*), void* val) {
	struct liblock_impl* impl = lock->impl;
	void* res;

	aquire(impl);
	
	res = pending(val);

	release(impl);

	return res;
}
コード例 #15
0
ファイル: posix.c プロジェクト: SANL-2015/SANL-2015
static void* do_liblock_execute_operation(posix)(liblock_lock_t* lock, void* (*pending)(void*), void* val) {
	struct liblock_impl* impl = lock->impl;
	void* res;

	//printf("posix locking %p\n", lock);
	pthread_mutex_lock(&impl->posix_lock);

	res = pending(val);

	pthread_mutex_unlock(&impl->posix_lock);
	
	return res;
}
コード例 #16
0
ファイル: sig.cpp プロジェクト: AlfiyaZi/GDCM
bool sig::ispending (int signo) const
{
#ifndef WIN32
  sigset_t s = pending ();
  switch (sigismember (&s, signo)) {
  case 0: return false;
  case 1: return true;
  }
  throw sigerr();
#else
  return true;//is this the right behavior for windows?
#endif //windows does not define sigset_t
}
コード例 #17
0
      long ctrl (BIO *b, int cmd, long num, void *ptr)
      {
	long ret = 1;

	switch (cmd)
	  {
	  case BIO_CTRL_RESET:
	    clear();
	    break;
	  case BIO_CTRL_EOF:
	    ret = (long)empty();
	    break;
	  case BIO_C_SET_BUF_MEM_EOF_RETURN:
	    b->num = (int)num;
	    break;
	  case BIO_CTRL_GET_CLOSE:
	    ret = (long)b->shutdown;
	    break;
	  case BIO_CTRL_SET_CLOSE:
	    b->shutdown = (int)num;
	    break;
	  case BIO_CTRL_WPENDING:
	    ret = 0L;
	    break;
	  case BIO_CTRL_PENDING:
	    ret = (long)pending();
	    break;
	  case BIO_CTRL_DUP:
	  case BIO_CTRL_FLUSH:
	    ret = 1;
	    break;
	  case BIO_CTRL_DGRAM_QUERY_MTU:
	    ret = mtu = query_mtu_return;
	    break;
	  case BIO_CTRL_DGRAM_GET_MTU:
	    ret = mtu;
	    break;
	  case BIO_CTRL_DGRAM_SET_MTU:
	    ret = mtu = num;
	    break;
	  case BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT:
	    std::memcpy(&next_timeout, ptr, sizeof(struct timeval));		
	    break;
	  default:
	    //OPENVPN_LOG("*** MemQ-dgram unimplemented ctrl method=" << cmd);
	    ret = 0;
	    break;
	  }
	return (ret);
      }
コード例 #18
0
ファイル: acid64.cpp プロジェクト: mwgoldsmith/sidplay2-libs
void Acid64::delay (event_clock_t cycles)
{
    cpuClock += cycles;
    if (!pending())
    {
        cycleCorrection += (long)cycles;
        while (cycleCorrection > 0xffff)
        {   // Issue delay operation
            command          = ACID64_CMD_DELAY;
            cmdCycles        = 0xffff;
            cycleCorrection -= 0xffff;
            SwitchToFiber (mainFiber);
        }
    }
}
コード例 #19
0
ファイル: streams.c プロジェクト: 2asoft/freebsd
/* Implements svn_stream_data_available_fn_t */
static svn_error_t *
sock_pending_cb(void *baton,
                svn_boolean_t *data_available)
{
  sock_baton_t *b = baton;
  apr_pollfd_t pfd;

  pfd.desc_type = APR_POLL_SOCKET;
  pfd.desc.s = b->sock;

  *data_available = pending(&pfd, b->pool);

  svn_pool_clear(b->pool);

  return SVN_NO_ERROR;
}
コード例 #20
0
ファイル: rcupdate.cpp プロジェクト: laborjack/L4Re
PUBLIC
void
Rcu_data::enter_idle(Rcu_glbl *rgp)
{
  if (EXPECT_TRUE(!_idle))
    {
      _idle = true;

      auto guard = lock_guard(rgp->_lock);
      rgp->_active_cpus.clear(_cpu);

      if (_q_batch != rgp->_current || _pending)
        {
          _q_batch = rgp->_current;
          _pending = 0;
          rgp->cpu_quiet(_cpu);
          assert (!pending(rgp));
        }
    }
}
コード例 #21
0
	long ctrl (BIO *b, int cmd, long num, void *ptr)
	{
		long ret = 1;

		switch (cmd)
		{
		case BIO_CTRL_RESET:
			clear();
			break;
		case BIO_CTRL_EOF:
			ret = (long)empty();
			break;
		case BIO_C_SET_BUF_MEM_EOF_RETURN:
			b->num = (int)num;
			break;
		case BIO_CTRL_GET_CLOSE:
			ret = (long)b->shutdown;
			break;
		case BIO_CTRL_SET_CLOSE:
			b->shutdown = (int)num;
			break;
		case BIO_CTRL_WPENDING:
			ret = 0L;
			break;
		case BIO_CTRL_PENDING:
			ret = (long)pending();
			break;
		case BIO_CTRL_DUP:
		case BIO_CTRL_FLUSH:
			ret = 1;
			break;
		default:
			//OPENVPN_LOG("*** MemQ-stream unimplemented ctrl method=" << cmd);
			ret = 0;
			break;
		}
		return (ret);
	}
コード例 #22
0
ファイル: HTTPServer.cpp プロジェクト: szakats/bzflag_mirror
void HTTPServer::process(bz_EventData *eventData)
{
  if (eventData->eventType == bz_eTickEvent) {
    update();
  } else {
    bz_NewNonPlayerConnectionEventData_V1 *connData = (bz_NewNonPlayerConnectionEventData_V1*)eventData;

    // log out the data if our level is high enough
    if (bz_getDebugLevel() >= 4) {
      char *temp = (char*)malloc(connData->size+1);
      memcpy(temp,connData->data,connData->size);
      temp[connData->size] = 0;
      bz_debugMessagef(4,"Plug-in HTTPServer: Non ProtoConnection connection from %d with %s",connData->connectionID,temp);
      free(temp);
    }

    // we go an accept everyone so that we can see if they are going to give us an HTTP command
    if(bz_registerNonPlayerConnectionHandler(connData->connectionID, this)) {
      // record the connection
      HTTPConnection connection;
      connection.connectionID = connData->connectionID;
      connection.request = eUnknown;
      connection.sessionID = generateSessionID();  // new ID in case they don't have one

      HTTPConnectionMap::iterator itr = liveConnections.find(connection.connectionID);

      if (itr != liveConnections.end())
	liveConnections.erase(itr);	// something weird is happening here

      liveConnections[connection.connectionID] = connection;

      // go and process any data they have and see what the deal is
      pending(connData->connectionID, (char*)connData->data, connData->size);
    }
  }
}
コード例 #23
0
static void *
fd_resource_transfer_map(struct pipe_context *pctx,
		struct pipe_resource *prsc,
		unsigned level, unsigned usage,
		const struct pipe_box *box,
		struct pipe_transfer **pptrans)
{
	struct fd_context *ctx = fd_context(pctx);
	struct fd_resource *rsc = fd_resource(prsc);
	struct fd_resource_slice *slice = fd_resource_slice(rsc, level);
	struct fd_transfer *trans;
	struct pipe_transfer *ptrans;
	enum pipe_format format = prsc->format;
	uint32_t op = 0;
	uint32_t offset;
	char *buf;
	int ret = 0;

	DBG("prsc=%p, level=%u, usage=%x, box=%dx%d+%d,%d", prsc, level, usage,
		box->width, box->height, box->x, box->y);

	ptrans = util_slab_alloc(&ctx->transfer_pool);
	if (!ptrans)
		return NULL;

	/* util_slab_alloc() doesn't zero: */
	trans = fd_transfer(ptrans);
	memset(trans, 0, sizeof(*trans));

	pipe_resource_reference(&ptrans->resource, prsc);
	ptrans->level = level;
	ptrans->usage = usage;
	ptrans->box = *box;
	ptrans->stride = util_format_get_nblocksx(format, slice->pitch) * rsc->cpp;
	ptrans->layer_stride = rsc->layer_first ? rsc->layer_size : slice->size0;

	if (usage & PIPE_TRANSFER_READ)
		op |= DRM_FREEDRENO_PREP_READ;

	if (usage & PIPE_TRANSFER_WRITE)
		op |= DRM_FREEDRENO_PREP_WRITE;

	if (usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE) {
		realloc_bo(rsc, fd_bo_size(rsc->bo));
		if (rsc->stencil)
			realloc_bo(rsc->stencil, fd_bo_size(rsc->stencil->bo));
		fd_invalidate_resource(ctx, prsc);
	} else if ((usage & PIPE_TRANSFER_WRITE) &&
			   prsc->target == PIPE_BUFFER &&
			   !util_ranges_intersect(&rsc->valid_buffer_range,
									  box->x, box->x + box->width)) {
		/* We are trying to write to a previously uninitialized range. No need
		 * to wait.
		 */
	} else if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
		/* If the GPU is writing to the resource, or if it is reading from the
		 * resource and we're trying to write to it, flush the renders.
		 */
		if (((ptrans->usage & PIPE_TRANSFER_WRITE) &&
					pending(rsc, FD_PENDING_READ | FD_PENDING_WRITE)) ||
				pending(rsc, FD_PENDING_WRITE))
			fd_context_render(pctx);

		/* The GPU keeps track of how the various bo's are being used, and
		 * will wait if necessary for the proper operation to have
		 * completed.
		 */
		ret = fd_bo_cpu_prep(rsc->bo, ctx->screen->pipe, op);
		if (ret)
			goto fail;
	}

	buf = fd_bo_map(rsc->bo);
	if (!buf)
		goto fail;

	offset = slice->offset +
		box->y / util_format_get_blockheight(format) * ptrans->stride +
		box->x / util_format_get_blockwidth(format) * rsc->cpp +
		fd_resource_layer_offset(rsc, slice, box->z);

	if (prsc->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT ||
		prsc->format == PIPE_FORMAT_X32_S8X24_UINT) {
		assert(trans->base.box.depth == 1);

		trans->base.stride = trans->base.box.width * rsc->cpp * 2;
		trans->staging = malloc(trans->base.stride * trans->base.box.height);
		if (!trans->staging)
			goto fail;

		/* if we're not discarding the whole range (or resource), we must copy
		 * the real data in.
		 */
		if (!(usage & (PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE |
					   PIPE_TRANSFER_DISCARD_RANGE))) {
			struct fd_resource_slice *sslice =
				fd_resource_slice(rsc->stencil, level);
			void *sbuf = fd_bo_map(rsc->stencil->bo);
			if (!sbuf)
				goto fail;

			float *depth = (float *)(buf + slice->offset +
				fd_resource_layer_offset(rsc, slice, box->z) +
				box->y * slice->pitch * 4 + box->x * 4);
			uint8_t *stencil = sbuf + sslice->offset +
				fd_resource_layer_offset(rsc->stencil, sslice, box->z) +
				box->y * sslice->pitch + box->x;

			if (format != PIPE_FORMAT_X32_S8X24_UINT)
				util_format_z32_float_s8x24_uint_pack_z_float(
						trans->staging, trans->base.stride,
						depth, slice->pitch * 4,
						box->width, box->height);

			util_format_z32_float_s8x24_uint_pack_s_8uint(
					trans->staging, trans->base.stride,
					stencil, sslice->pitch,
					box->width, box->height);
		}

		buf = trans->staging;
		offset = 0;
	} else if (rsc->internal_format != format &&
			   util_format_description(format)->layout == UTIL_FORMAT_LAYOUT_RGTC) {
		assert(trans->base.box.depth == 1);

		trans->base.stride = util_format_get_stride(
				format, trans->base.box.width);
		trans->staging = malloc(
				util_format_get_2d_size(format, trans->base.stride,
										trans->base.box.height));
		if (!trans->staging)
			goto fail;

		/* if we're not discarding the whole range (or resource), we must copy
		 * the real data in.
		 */
		if (!(usage & (PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE |
					   PIPE_TRANSFER_DISCARD_RANGE))) {
			uint8_t *rgba8 = (uint8_t *)buf + slice->offset +
				fd_resource_layer_offset(rsc, slice, box->z) +
				box->y * slice->pitch * rsc->cpp + box->x * rsc->cpp;

			switch (format) {
			case PIPE_FORMAT_RGTC1_UNORM:
			case PIPE_FORMAT_RGTC1_SNORM:
			case PIPE_FORMAT_LATC1_UNORM:
			case PIPE_FORMAT_LATC1_SNORM:
				util_format_rgtc1_unorm_pack_rgba_8unorm(
					trans->staging, trans->base.stride,
					rgba8, slice->pitch * rsc->cpp,
					box->width, box->height);
				break;
			case PIPE_FORMAT_RGTC2_UNORM:
			case PIPE_FORMAT_RGTC2_SNORM:
			case PIPE_FORMAT_LATC2_UNORM:
			case PIPE_FORMAT_LATC2_SNORM:
				util_format_rgtc2_unorm_pack_rgba_8unorm(
					trans->staging, trans->base.stride,
					rgba8, slice->pitch * rsc->cpp,
					box->width, box->height);
				break;
			default:
				assert(!"Unexpected format");
				break;
			}
		}

		buf = trans->staging;
		offset = 0;
	}

	*pptrans = ptrans;

	return buf + offset;

fail:
	fd_resource_transfer_unmap(pctx, ptrans);
	return NULL;
}
コード例 #24
0
ファイル: daemon.c プロジェクト: plepe/mod_tile
enum protoCmd rx_request(const struct protocol *req, int fd)
{
    struct protocol *reqnew;
    struct item *list = NULL, *item;
    enum protoCmd pend;

    // Upgrade version 1 to version 2
    if (req->ver == 1) {
        reqnew = (struct protocol *)malloc(sizeof(struct protocol));
        memcpy(reqnew, req, sizeof(struct protocol_v1));
        reqnew->xmlname[0] = 0;
        req = reqnew;
    }
    else if (req->ver != 2) {
        syslog(LOG_ERR, "Bad protocol version %d", req->ver);
        return cmdIgnore;
    }

    syslog(LOG_DEBUG, "DEBUG: Got command %s fd(%d) xml(%s), z(%d), x(%d), y(%d)",
            cmdStr(req->cmd), fd, req->xmlname, req->z, req->x, req->y);

    if ((req->cmd != cmdRender) && (req->cmd != cmdRenderPrio) && (req->cmd != cmdDirty) && (req->cmd != cmdRenderBulk))
        return cmdIgnore;

    item = (struct item *)malloc(sizeof(*item));
    if (!item) {
            syslog(LOG_ERR, "malloc failed");
            return cmdNotDone;
    }

    item->req = *req;
    item->duplicates = NULL;
    item->fd = (req->cmd == cmdDirty) ? FD_INVALID : fd;

    item_load(item, req);

#ifdef METATILE
    /* Round down request co-ordinates to the neareast N (should be a power of 2)
     * Note: request path is no longer consistent but this will be recalculated
     * when the metatile is being rendered.
     */
    item->mx = item->req.x & ~(METATILE-1);
    item->my = item->req.y & ~(METATILE-1);
#else
    item->mx = item->req.x;
    item->my = item->req.y;
#endif

    pthread_mutex_lock(&qLock);

    // Check for a matching request in the current rendering or dirty queues
    pend = pending(item);
    if (pend == cmdNotDone) {
        // We found a match in the dirty queue, can not wait for it
        pthread_mutex_unlock(&qLock);
        free(item);
        return cmdNotDone;
    }
    if (pend == cmdIgnore) {
        // Found a match in render queue, item added as duplicate
        pthread_mutex_unlock(&qLock);
        return cmdIgnore;
    }

    // New request, add it to render or dirty queue
    if ((req->cmd == cmdRender) && (reqNum < REQ_LIMIT)) {
        list = &reqHead;
        item->inQueue = queueRequest;
        reqNum++;
    } else if ((req->cmd == cmdRenderPrio) && (reqPrioNum < REQ_LIMIT)) {
        list = &reqPrioHead;
        item->inQueue = queueRequestPrio;
        reqPrioNum++;
    } else if ((req->cmd == cmdRenderBulk) && (reqBulkNum < REQ_LIMIT)) {
        list = &reqBulkHead;
        item->inQueue = queueRequestBulk;
        reqBulkNum++;
    } else if (dirtyNum < DIRTY_LIMIT) {
        list = &dirtyHead;
        item->inQueue = queueDirty;
        dirtyNum++;
        item->fd = FD_INVALID; // No response after render
    } else {
        // The queue is severely backlogged. Drop request
        stats.noReqDroped++;
        pthread_mutex_unlock(&qLock);
        free(item);
        return cmdNotDone;
    }

    if (list) {
        item->next = list;
        item->prev = list->prev;
        item->prev->next = item;
        list->prev = item;
        /* In addition to the linked list, add item to a hash table index
         * for faster lookup of pending requests.
         */
        insert_item_idx(item);

        pthread_cond_signal(&qCond);
    } else
        free(item);

    pthread_mutex_unlock(&qLock);

    return (list == &reqHead)?cmdIgnore:cmdNotDone;
}
コード例 #25
0
 context_pointer context() {
   BOOST_ASSERT(pending());
   return m_coro_impl;
 }
コード例 #26
0
enum protoCmd request_queue_add_request(struct request_queue * queue, struct item *item) {
    enum protoCmd status;
    const struct protocol *req;
    struct item *list = NULL;
    req = &(item->req);
    if (queue == NULL) {
        printf("queue os NULL");
        exit(3);
    }

    pthread_mutex_lock(&(queue->qLock));

    // Check for a matching request in the current rendering or dirty queues
    status = pending(queue, item);
    if (status == cmdNotDone) {
        // We found a match in the dirty queue, can not wait for it
        pthread_mutex_unlock(&(queue->qLock));
        free(item);
        return cmdNotDone;
    }
    if (status == cmdIgnore) {
        // Found a match in render queue, item added as duplicate
        pthread_mutex_unlock(&(queue->qLock));
        return cmdIgnore;
    }

    // New request, add it to render or dirty queue
    if ((req->cmd == cmdRender) && (queue->reqNum < REQ_LIMIT)) {
        list = &(queue->reqHead);
        item->inQueue = queueRequest;
        item->originatedQueue = queueRequest;
        queue->reqNum++;
    } else if ((req->cmd == cmdRenderPrio) && (queue->reqPrioNum < REQ_LIMIT)) {
        list = &(queue->reqPrioHead);
        item->inQueue = queueRequestPrio;
        item->originatedQueue = queueRequestPrio;
        queue->reqPrioNum++;
    } else if ((req->cmd == cmdRenderLow) && (queue->reqLowNum < REQ_LIMIT)) {
        list = &(queue->reqLowHead);
        item->inQueue = queueRequestLow;
        item->originatedQueue = queueRequestLow;
        queue->reqLowNum++;
    } else if ((req->cmd == cmdRenderBulk) && (queue->reqBulkNum < REQ_LIMIT)) {
        list = &(queue->reqBulkHead);
        item->inQueue = queueRequestBulk;
        item->originatedQueue = queueRequestBulk;
        queue->reqBulkNum++;
    } else if (queue->dirtyNum < DIRTY_LIMIT) {
        list = &(queue->dirtyHead);
        item->inQueue = queueDirty;
        item->originatedQueue = queueDirty;
        queue->dirtyNum++;
        item->fd = FD_INVALID; // No response after render
    } else {
        // The queue is severely backlogged. Drop request
        queue->stats.noReqDroped++;
        pthread_mutex_unlock(&(queue->qLock));
        free(item);
        return cmdNotDone;
    }

    if (list) {
        item->next = list;
        item->prev = list->prev;
        item->prev->next = item;
        list->prev = item;
        /* In addition to the linked list, add item to a hash table index
         * for faster lookup of pending requests.
         */
        insert_item_idx(queue, item);

        pthread_cond_signal(&queue->qCond);
    } else
        free(item);

    pthread_mutex_unlock(&queue->qLock);

    return (list == &(queue->dirtyHead))?cmdNotDone:cmdIgnore;
}
コード例 #27
0
void BasicStep::pending() {
    pending(0);
}
コード例 #28
0
ファイル: requests.cpp プロジェクト: Botrix/pentago
void requests_t::waitsome() {
  thread_time_t time(wait_kind,unevent);
  for (;;) {
    // Check for MPI request completions
    {
      int n = requests.size();
      GEODE_ASSERT(n);
      MPI_Status statuses[n];
      int indices[n];
      int finished;
      const auto check = PENTAGO_MPI_FUNNEL?MPI_Testsome:MPI_Waitsome;
      CHECK(check(n,requests.data(),&finished,indices,statuses));
      if (finished) { // If any requests finished, call their callbacks and return
        time.stop();
        // Add requested callback to pending list
        vector<Tuple<function<void(MPI_Status*)>,MPI_Status*>> pending(finished);
        for (int i=0;i<finished;i++) {
          int j = indices[i];
          if (callbacks[j]) {
            swap(pending[i].x,callbacks[j]);
            pending[i].y = &statuses[i];
          }
        }
        // The MPI standard doesn't appear to specify whether the indices are sorted.  Removing an unsorted list
        // of elements from an array is very unpleasant, so we sort.  If they're already sorted, this is cheap.
        insertion_sort(finished,indices);
        // Prune away satisfied requests
        for (int i=finished-1;i>=0;i--) {
          int j = indices[i];
          requests.remove_index_lazy(j);
          cancellables.remove_index_lazy(j);
          callbacks[j].swap(callbacks[--n]);
        }
        callbacks.resize(n);
        // Launch pending callbacks
        for (auto& pair : pending)
          if (pair.x)
            pair.x(pair.y);
        return;
      } else if (!PENTAGO_MPI_FUNNEL)
        die("MPI_Waitsome completed with zero requests out of %d",n);
    }
#if PENTAGO_MPI_FUNNEL
    // Check for messages from worker threads
    if (immediate_count) {
      // Pull callbacks off shared pile
      immediate_lock.lock();
      const int n = immediate_count;
      job_base_t* ready[n];
      if (n) {
        immediate_count = 0;
        memcpy(ready,&immediates[0],sizeof(job_base_t*)*n);
        immediates.clear();
      }
      immediate_lock.unlock();
      // If we have any, run them
      if (n) {
        time.stop();
        // If exceptions are thrown here there'd be a memory leak, but we don't allow exceptions.
        for (const auto job : ready) {
          (*job)();
          delete job;
        }
        return;
      }
    }
#endif
  }
}
コード例 #29
0
ファイル: future.hpp プロジェクト: alepharchives/coroutine
 future& operator=(none_t) {
   BOOST_ASSERT(!pending());
   m_ptr->get() = none;
   return *this;
 }
コード例 #30
0
ファイル: future.hpp プロジェクト: alepharchives/coroutine
 future& operator=(const value_type& rhs) {
   BOOST_ASSERT(!pending());
   m_ptr->get() = tuple_type(rhs);
   return *this;
 }