本文整理汇总了C++中ready函数的典型用法代码示例。如果您正苦于以下问题:C++ ready函数的具体用法?C++ ready怎么用?C++ ready使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ready函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PHDBG
void PhVideoDecoder::decodeFrame()
{
if(!ready()) {
PHDBG(24) << "not ready";
return;
}
if (_requestedFrames.empty()) {
// all pending requests have been cancelled
return;
}
// now proceed with the first requested frame
PhVideoBuffer *buffer = _requestedFrames.takeFirst();
PhFrame frame = buffer->requestFrame();
// resize the buffer if needed
int bufferSize = avpicture_get_size(AV_PIX_FMT_BGRA, width(), height());
if(bufferSize <= 0) {
PHERR << "avpicture_get_size() returned" << bufferSize;
return;
}
buffer->reuse(bufferSize);
// clip to stream boundaries
if(frame < 0)
frame = 0;
if (frame >= this->frameLength())
frame = this->frameLength();
// Stay with the same frame if the time has changed less than the time between two frames
// Note that av_seek_frame will seek to the _closest_ frame, sometimes a little bit in the "future",
// so it is necessary to use a little margin for the second comparison, otherwise a seek may
// be performed on each call to decodeFrame
if (frame == _currentFrame) {
frameToRgb(_videoFrame, buffer);
return;
}
// we need to perform a frame seek if the requested frame is:
// 1) in the past
// 2) after the next keyframe
// how to know when the next keyframe is ??
// -> for now we take a arbitrary threshold of 20 frames
if((frame < _currentFrame) || (frame >= _currentFrame + 20)) {
// seek to the closest keyframe in the past
int flags = AVSEEK_FLAG_BACKWARD;
int64_t timestamp = PhFrame_to_AVTimestamp(frame);
PHDBG(24) << "seek:" << buffer << " " << _currentFrame << " " << frame - _currentFrame << " " << timestamp;
av_seek_frame(_formatContext, _videoStream->index, timestamp, flags);
avcodec_flush_buffers(_videoStream->codec);
}
AVPacket packet;
bool lookingForVideoFrame = true;
while(lookingForVideoFrame) {
int error = av_read_frame(_formatContext, &packet);
switch(error) {
case 0:
if(packet.stream_index == _videoStream->index) {
int frameFinished = 0;
avcodec_decode_video2(_videoStream->codec, _videoFrame, &frameFinished, &packet);
if(frameFinished) {
// update the current position of the engine
// (Note that it is best not to do use '_currentTime = time' here, because the seeking operation may
// not be 100% accurate: the actual time may be different from the requested time. So a time drift
// could appear.)
_currentFrame = AVTimestamp_to_PhFrame(av_frame_get_best_effort_timestamp(_videoFrame));
PHDBG(24) << frame << _currentFrame;
if (frame < _currentFrame) {
// something went wrong with the seeking
// this is not going to work! we cannot go backward!
// the loop will go until the end of the file, which is bad...
// So stop here and just return what we have.
PHERR << "current video time is larger than requested time... returning current frame!";
frameToRgb(_videoFrame, buffer);
lookingForVideoFrame = false;
}
// convert and emit the frame if this is the one that was requested
if (frame == _currentFrame) {
PHDBG(24) << "decoded!";
frameToRgb(_videoFrame, buffer);
lookingForVideoFrame = false;
}
} // if frame decode is not finished, let's read another packet.
}
else if(_audioStream && (packet.stream_index == _audioStream->index)) {
int ok = 0;
avcodec_decode_audio4(_audioStream->codec, _audioFrame, &ok, &packet);
if(ok) {
PHDBG(24) << "audio:" << _audioFrame->nb_samples;
}
}
break;
case AVERROR_INVALIDDATA:
//.........这里部分代码省略.........
示例2: chanrecv
static bool
chanrecv ( ChanType *t , Hchan* c , byte *ep , bool block , bool *received )
{
SudoG *sg;
SudoG mysg;
G *gp;
int64 t0;
#line 214 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( debug )
runtime·printf ( "chanrecv: chan=%p\n" , c ) ;
#line 217 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( c == nil ) {
USED ( t ) ;
if ( !block )
return false;
runtime·park ( nil , nil , "chan receive (nil chan)" ) ;
return false;
}
#line 225 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
t0 = 0;
mysg.releasetime = 0;
if ( runtime·blockprofilerate > 0 ) {
t0 = runtime·cputicks ( ) ;
mysg.releasetime = -1;
}
#line 232 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
runtime·lock ( c ) ;
if ( c->dataqsiz > 0 )
goto asynch;
#line 236 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( c->closed )
goto closed;
#line 239 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
sg = dequeue ( &c->sendq ) ;
if ( sg != nil ) {
if ( raceenabled )
racesync ( c , sg ) ;
runtime·unlock ( c ) ;
#line 245 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( ep != nil )
c->elemtype->alg->copy ( c->elemsize , ep , sg->elem ) ;
gp = sg->g;
gp->param = sg;
if ( sg->releasetime )
sg->releasetime = runtime·cputicks ( ) ;
runtime·ready ( gp ) ;
#line 253 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( received != nil )
*received = true;
return true;
}
#line 258 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( !block ) {
runtime·unlock ( c ) ;
return false;
}
#line 263 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
mysg.elem = ep;
mysg.g = g;
mysg.selectdone = nil;
g->param = nil;
enqueue ( &c->recvq , &mysg ) ;
runtime·parkunlock ( c , "chan receive" ) ;
#line 270 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( g->param == nil ) {
runtime·lock ( c ) ;
if ( !c->closed )
runtime·throw ( "chanrecv: spurious wakeup" ) ;
goto closed;
}
#line 277 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( received != nil )
*received = true;
if ( mysg.releasetime > 0 )
runtime·blockevent ( mysg.releasetime - t0 , 2 ) ;
return true;
#line 283 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
asynch:
if ( c->qcount <= 0 ) {
if ( c->closed )
goto closed;
#line 288 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( !block ) {
runtime·unlock ( c ) ;
if ( received != nil )
*received = false;
return false;
}
mysg.g = g;
mysg.elem = nil;
mysg.selectdone = nil;
enqueue ( &c->recvq , &mysg ) ;
runtime·parkunlock ( c , "chan receive" ) ;
#line 300 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
runtime·lock ( c ) ;
goto asynch;
}
#line 304 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( raceenabled ) {
runtime·raceacquire ( chanbuf ( c , c->recvx ) ) ;
//.........这里部分代码省略.........
示例3: chansend
static bool
chansend ( ChanType *t , Hchan *c , byte *ep , bool block , void *pc )
{
SudoG *sg;
SudoG mysg;
G* gp;
int64 t0;
#line 82 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( raceenabled )
runtime·racereadobjectpc ( ep , t->elem , runtime·getcallerpc ( &t ) , chansend ) ;
#line 85 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( c == nil ) {
USED ( t ) ;
if ( !block )
return false;
runtime·park ( nil , nil , "chan send (nil chan)" ) ;
return false;
}
#line 93 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( debug ) {
runtime·printf ( "chansend: chan=%p; elem=" , c ) ;
c->elemtype->alg->print ( c->elemsize , ep ) ;
runtime·prints ( "\n" ) ;
}
#line 99 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
t0 = 0;
mysg.releasetime = 0;
if ( runtime·blockprofilerate > 0 ) {
t0 = runtime·cputicks ( ) ;
mysg.releasetime = -1;
}
#line 106 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
runtime·lock ( c ) ;
if ( raceenabled )
runtime·racereadpc ( c , pc , chansend ) ;
if ( c->closed )
goto closed;
#line 112 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( c->dataqsiz > 0 )
goto asynch;
#line 115 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
sg = dequeue ( &c->recvq ) ;
if ( sg != nil ) {
if ( raceenabled )
racesync ( c , sg ) ;
runtime·unlock ( c ) ;
#line 121 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
gp = sg->g;
gp->param = sg;
if ( sg->elem != nil )
c->elemtype->alg->copy ( c->elemsize , sg->elem , ep ) ;
if ( sg->releasetime )
sg->releasetime = runtime·cputicks ( ) ;
runtime·ready ( gp ) ;
return true;
}
#line 131 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( !block ) {
runtime·unlock ( c ) ;
return false;
}
#line 136 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
mysg.elem = ep;
mysg.g = g;
mysg.selectdone = nil;
g->param = nil;
enqueue ( &c->sendq , &mysg ) ;
runtime·parkunlock ( c , "chan send" ) ;
#line 143 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( g->param == nil ) {
runtime·lock ( c ) ;
if ( !c->closed )
runtime·throw ( "chansend: spurious wakeup" ) ;
goto closed;
}
#line 150 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( mysg.releasetime > 0 )
runtime·blockevent ( mysg.releasetime - t0 , 2 ) ;
#line 153 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
return true;
#line 155 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
asynch:
if ( c->closed )
goto closed;
#line 159 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
if ( c->qcount >= c->dataqsiz ) {
if ( !block ) {
runtime·unlock ( c ) ;
return false;
}
mysg.g = g;
mysg.elem = nil;
mysg.selectdone = nil;
enqueue ( &c->sendq , &mysg ) ;
runtime·parkunlock ( c , "chan send" ) ;
#line 170 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
runtime·lock ( c ) ;
goto asynch;
}
#line 174 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"
//.........这里部分代码省略.........
示例4: service_change_handler
static void service_change_handler(BTDevice device,
const BLEService services[],
uint8_t num_services,
BTErrno status) {
// out with the old...
node_ctx.node_service_1_characteristic = BLE_CHARACTERISTIC_INVALID;
node_ctx.node_command_characteristic = BLE_CHARACTERISTIC_INVALID;
node_ctx.node_service_4_characteristic = BLE_CHARACTERISTIC_INVALID;
node_ctx.node_service_6_characteristic = BLE_CHARACTERISTIC_INVALID;
for (uint8_t i = 0; i < num_services; ++i) {
Uuid service_uuid = ble_service_get_uuid(services[i]);
const Uuid node_service_uuid =
UuidMake(0xda, 0x2b, 0x84, 0xf1, 0x62, 0x79, 0x48, 0xde,
0xbd, 0xc0, 0xaf, 0xbe, 0xa0, 0x22, 0x60, 0x79);
if (!uuid_equal(&service_uuid, &node_service_uuid)) {
// Not the Bean's "Scratch Service"
continue;
}
char uuid_buffer[UUID_STRING_BUFFER_LENGTH];
uuid_to_string(&service_uuid, uuid_buffer);
const BTDeviceAddress address = bt_device_get_address(device);
APP_LOG(APP_LOG_LEVEL_INFO,
"Discovered Node+ service %s (0x%08x) on " BT_DEVICE_ADDRESS_FMT,
uuid_buffer,
services[i],
BT_DEVICE_ADDRESS_XPLODE(address));
// Iterate over the characteristics within the "Scratch Service":
BLECharacteristic characteristics[6];
uint8_t num_characteristics =
ble_service_get_characteristics(services[i], characteristics, 8);
if (num_characteristics > 6) {
num_characteristics = 6;
}
for (uint8_t c = 0; c < num_characteristics; ++c) {
Uuid characteristic_uuid = ble_characteristic_get_uuid(characteristics[c]);
// The characteristic UUIDs we're looking for:
const Uuid node_service_1_uuid =
UuidMake(0xa8, 0x79, 0x88, 0xb9, 0x69, 0x4c, 0x47, 0x9c,
0x90, 0x0e, 0x95, 0xdf, 0xa6, 0xc0, 0x0a, 0x24);
const Uuid node_command_uuid =
UuidMake(0xbf, 0x03, 0x26, 0x0c, 0x72, 0x05, 0x4c, 0x25,
0xaf, 0x43, 0x93, 0xb1, 0xc2, 0x99, 0xd1, 0x59);
const Uuid node_service_4_uuid =
UuidMake(0x18, 0xcd, 0xa7, 0x84, 0x4b, 0xd3, 0x43, 0x70,
0x85, 0xbb, 0xbf, 0xed, 0x91, 0xec, 0x86, 0xaf);
const Uuid node_service_6_uuid =
UuidMake(0xfd, 0xd6, 0xb4, 0xd3, 0x04, 0x6d, 0x43, 0x30,
0xbd, 0xec, 0x1f, 0xd0, 0xc9, 0x0c, 0xb4, 0x3b);
uint8_t node_num = 0; // Just for logging purposes
if (uuid_equal(&characteristic_uuid, &node_service_1_uuid)) {
// Found node service 1
node_ctx.node_service_1_characteristic = characteristics[c];
node_num = 1;
} else if (uuid_equal(&characteristic_uuid, &node_command_uuid)) {
// Found node command
node_ctx.node_command_characteristic = characteristics[c];
node_num = 2;
} else if (uuid_equal(&characteristic_uuid, &node_service_4_uuid)) {
// Found node command
node_ctx.node_service_4_characteristic = characteristics[c];
node_num = 3;
} else if (uuid_equal(&characteristic_uuid, &node_service_6_uuid)) {
// Found node command
node_ctx.node_service_6_characteristic = characteristics[c];
node_num = 4;
} else {
continue;
}
uuid_to_string(&characteristic_uuid, uuid_buffer);
APP_LOG(APP_LOG_LEVEL_INFO, "-- Found %u: %s (0x%08x)",
node_num, uuid_buffer, characteristics[c]);
// Check if all characteristics are found
if (node_ctx.node_service_1_characteristic != BLE_CHARACTERISTIC_INVALID &&
node_ctx.node_command_characteristic != BLE_CHARACTERISTIC_INVALID &&
node_ctx.node_service_4_characteristic != BLE_CHARACTERISTIC_INVALID &&
node_ctx.node_service_6_characteristic != BLE_CHARACTERISTIC_INVALID) {
ready();
}
}
}
}
示例5: disconnect
void ELoginAction::continue1()
{
disconnect(&s_browser,SIGNAL(ready()),this,SLOT(continue1()));
s_browser.loadPage("http://www.ontariots.ca//?q=user/login");
connect(&s_browser,SIGNAL(ready()),this,SLOT(continue2()));
}
示例6: emit
/*!
called by callback when done reading data
*/
void AudioReaderPortAudio::emitAudioReady()
{
bptr++;
bptr = bptr % bpmax;
emit(ready(buff, bptr));
}
示例7: DownloadBot
/* ------------------------------------------------------------------------------*/
void DownloadBot(char *path)
{
SOCKADDR_IN sin;
SOCKET s = NULL;
WSADATA wsaData;
HANDLE file = NULL;
int done = 0;
char buf[BUF_SIZE];
DWORD bytes = 0,written = 0;
int iResult;
char source_file[128];
char source_host[128];
char loader_version[255];
strncpy(source_file, SOURCE_FILE, sizeof(source_file));
strncpy(loader_version, LOADER_VERSION, sizeof(loader_version));
strncpy(source_host, SOURCE_HOST, sizeof(source_host));
while(!done)
{
deb("entered download cycle");
deb("source_host: %s", source_host);
deb("loader_version: %s", loader_version);
deb("source_file: %s", source_file);
Sleep(100);
if(file && file != INVALID_HANDLE_VALUE)
CloseHandle(file);
if(s && s != INVALID_SOCKET)
closesocket(s);
file = CreateFile(path,GENERIC_ALL,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(file == INVALID_HANDLE_VALUE)
{
deb("DownloadFile: failed to create file %s\n", fmterr());
continue;
}
iResult = WSAStartup(MAKEWORD(2,2), &wsaData);
sin.sin_family = AF_INET;
sin.sin_port = htons(SOURCE_PORT);
if(DnsResolve(source_host) == -1)
continue;
sin.sin_addr.s_addr = DnsResolve(source_host);
s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (s == INVALID_SOCKET)
{
deb("socket: %s", fmterr());
continue;
}
if(connect( s, (SOCKADDR*) &sin, sizeof(sin) ) == SOCKET_ERROR)
{
deb("connect: %s\n",fmterr());
continue;
}
wsprintf(buf,"GET %s HTTP/1.0\r\n"
"User-Agent: %s\r\n"
"Host: %s\r\n\r\n",source_file, loader_version, source_host);
int res = send(s,buf,lstrlen(buf),0);
if(res == SOCKET_ERROR)
{
deb("res == SOCKET_ERROR after send()");
continue;
}
int code = GetHTTPRespCode(s);
if(code != 200)
{
deb("code: %d",code);
continue;
}
while(ready(s,HTTP_TIMEOUT) == 0)
{
res = recv(s,buf,BUF_SIZE,0);
if(res == SOCKET_ERROR)
break;
if(res == 0)
{
done = 1;
closesocket(s);
CloseHandle(file);
break;
}
bytes += res;
WriteFile(file,buf,res,&written,NULL);
if(written != (DWORD) res)
break;
//.........这里部分代码省略.........
示例8: main
int main(int argc, char **argv)
{
srand(time(NULL));
int rank, size;
MPI_Init(&argc, &argv);
MPI_Comm_size(MPI_COMM_WORLD, &size);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Status status;
// lista procesów ubiegających się o trupa
int U[size];
// tablica trupów - założyłem 100
int T[100] = {0};
// zegar lamporta
int C = 0;
int i = 0;
for (i = 0; i < size; i++)
U[i] = 0;
while(!ready(T, 100))
{
int trup_id = rand() % 100;
printf("rank %d: chce %d", rank, trup_id);
int message[MSG_LENGTH] = { rank, PROCESSED, trup_id, C };
sendAllInU(message, size, U, rank, C);
U[rank] = 1;
T[trup_id] = 1;
int status = 0;
do
{
int response[4];
MPI_Recv( &response, MSG_LENGTH, MPI_INT, MPI_ANY_SOURCE, TAG, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
C = MAX(C, response[3]);
printf("rank %d: dostałem od %d, trup_id: %d, C=%d\n", rank, response[0], response[2], response[3]);
if ((response[2] == trup_id) && (response[0] < rank))
{
status = 1;
break;
}
else if (response[1] == BURIED)
{
U[response[0]] = -1;
T[response[2]] = BURIED;
}
else if (response[1] == BACK)
{
U[response[0]] = 0;
}
else
{
T[response[2]] = PROCESSED;
U[response[0]] = 1;
}
}
while (!readyU(U,size));
if (status)
continue;
C++;
int request[4] = {
rank, BURIED, trup_id, C
};
broadcast(request, size, rank, C);
sleep(2);
int flag;
MPI_Request req;
MPI_Status stat;
int response[4];
do
{
MPI_Irecv( &response, MSG_LENGTH, MPI_INT, MPI_ANY_SOURCE, TAG, MPI_COMM_WORLD, &req);
MPI_Test(&req, &flag, &stat);
}
while (flag);
}
MPI_Finalize();
}
示例9: error
void Game::message_handler(Server& server, int player, std::string msg)
{
std::vector<std::string> words;
boost::trim(msg);
boost::split(words, msg, boost::is_any_of("\t "), boost::token_compress_on);
if (words.empty()) {
error(server, player);
return;
}
if (words[0] == "ready") {
if (ready(player)) {
error(server, player);
return;
}
ready(player) = true;
player_color(player) = ready(other(player)) ? BLACK : WHITE;
server.send(player, "color " + show(player_color(player)));
if (ready1 && ready2) {
reset_playing();
server.broadcast("start");
}
} else if (words[0] == "say") {
std::stringstream ss;
ss << "say" << player;
for (size_t i = 1; i < words.size(); ++i) {
ss << " " << words[i];
}
server.broadcast(ss.str());
} else if (words[0] == "move") {
if (!playing || current_color != player_color(player) ||
words.size() != 3) {
server.send(player, "error move");
return;
}
boost::optional<Square> maybe_from = read_square(words[1]);
boost::optional<Square> maybe_to = read_square(words[2]);
if (!maybe_from || !maybe_to) {
error(server, player);
return;
}
boost::optional<MoveResult> maybe_move_result =
try_move(board, player_color(player), *maybe_from, *maybe_to);
if (!maybe_move_result) {
server.send(player, "error move");
return;
}
current_color = current_color == WHITE ? BLACK : WHITE;
if (maybe_move_result->opponent_cannot_move) {
reset_waiting();
}
server.broadcast(show(*maybe_move_result));
} else if (words[0] == "resign") {
if (!playing || current_color != player_color(player)) {
error(server, player);
return;
}
reset_waiting();
server.broadcast("resign");
} else {
error(server, player);
}
}
示例10: userinit
/*
* create the first process
*/
void
userinit(void)
{
Proc *p;
Segment *s;
KMap *k;
Page *pg;
/* no processes yet */
up = nil;
p = newproc();
p->pgrp = newpgrp();
p->egrp = smalloc(sizeof(Egrp));
p->egrp->ref = 1;
p->fgrp = dupfgrp(nil);
p->rgrp = newrgrp();
p->procmode = 0640;
kstrdup(&eve, "");
kstrdup(&p->text, "*init*");
kstrdup(&p->user, eve);
/*
* Kernel Stack
*/
p->sched.pc = PTR2UINT(init0);
p->sched.sp = PTR2UINT(p->kstack+KSTACK-sizeof(up->s.args)-sizeof(uintptr));
p->sched.sp = STACKALIGN(p->sched.sp);
/*
* User Stack
*
* Technically, newpage can't be called here because it
* should only be called when in a user context as it may
* try to sleep if there are no pages available, but that
* shouldn't be the case here.
*/
s = newseg(SG_STACK, USTKTOP-USTKSIZE, USTKSIZE/BY2PG);
p->seg[SSEG] = s;
pg = newpage(1, 0, USTKTOP-BY2PG);
segpage(s, pg);
k = kmap(pg);
bootargs(VA(k));
kunmap(k);
/*
* Text
*/
s = newseg(SG_TEXT, UTZERO, 1);
s->flushme++;
p->seg[TSEG] = s;
pg = newpage(1, 0, UTZERO);
memset(pg->cachectl, PG_TXTFLUSH, sizeof(pg->cachectl));
segpage(s, pg);
k = kmap(s->map[0]->pages[0]);
memmove(UINT2PTR(VA(k)), initcode, sizeof initcode);
kunmap(k);
ready(p);
}
示例11: switch
int GnuPGConnector::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QDeclarativeItem::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: ready(); break;
case 1: errorOccured(); break;
case 2: gpgFinished((*reinterpret_cast< int(*)>(_a[1]))); break;
case 3: gpgError((*reinterpret_cast< QProcess::ProcessError(*)>(_a[1]))); break;
case 4: { QString _r = encrypt((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 5: { QString _r = decrypt((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 6: { QString _r = showKeys();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 7: { QString _r = showSecretKeys();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 8: { QString _r = getData((*reinterpret_cast< bool(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 9: { QString _r = getFromClipboard();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 10: setToClipboard((*reinterpret_cast< QString(*)>(_a[1]))); break;
case 11: { QString _r = getKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 12: { QString _r = getKey((*reinterpret_cast< int(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 13: { QString _r = getKeyByID((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 14: { QString _r = getPrivateKeyIDs((*reinterpret_cast< bool(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 15: { QString _r = getPrivateKeyIDs();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 16: { int _r = getNumOfPubKeys((*reinterpret_cast< int(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
case 17: { int _r = getNumOfPubKeys();
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
case 18: { bool _r = generateKeyPair((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< QString(*)>(_a[4])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 19: { bool _r = setOwnerTrust((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 20: { bool _r = checkGPGVersion((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 21: { QString _r = getGPGVersionString();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 22: { bool _r = importKeysFromFile((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 23: { bool _r = importKeysFromClipboard();
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 24: { bool _r = searchKeysOnKeyserver((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 25: { bool _r = importKeysFromKeyserver((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 26: { bool _r = deleteKey((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 27: { bool _r = signKey((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 28: { bool _r = exportKeys((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 29: { QString _r = getHistory();
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 30: { bool _r = saveHistory((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break;
case 31: settingsSetValue((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
case 32: { QString _r = settingsGetValue((*reinterpret_cast< QString(*)>(_a[1])));
if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; } break;
case 33: settingsReset(); break;
default: ;
}
_id -= 34;
}
return _id;
}
示例12: docommand
//.........这里部分代码省略.........
}
break;
case F06 :
leavecell(sys.cell);
switch (choice(3,screenchoice))
{
case 1 :
if (tosavesys) savesys();
sys.screen = SCREEN1;
page = PAGEUP;
sys.cell.col = MONTH;
sys.cell.row = 8;
sys.display = HELDS;
genscreen();
break;
case 2 :
sys.screen = SCREEN2;
sys.display = HELDS;
page = PAGEUP;
sys.cell.row = 8;
sys.cell.col = EXPIRYDAY;
genscreen();
break;
case 3 :
if (tosavesys) savesys();
sys.cell.col = MONTH;
page = PAGEUP;
sys.screen = SCREEN3;
sys.display = INVVOL;
sys.cell.row = 8;
wait();
if (recalcvolvalues)
calcallvol();
ready();
genscreen();
break;
}
showtotals();
entercell(sys.cell);
break;
case F07 :
switch(choice(3,clearchoice))
{
case 1 : if (sys.cell.row < 8 || sys.screen == SCREEN2) break;
wait();
clearrow();
calcall();
showall();
totals();
entercell(sys.cell);
break;
case 2 : wait();
switch( sys.cell.col)
{
case VOLC :
case VALUEC :
case VOLP :
case DELTAC :
case VALUEP :
case DELTAP:
case SHAREPRICE :break;
case STOCKHELD : status.stockheld = 0; break;
case VOLATILITY : status.volatility = 0.0;break;
case INTEREST : status.interest = 0.0; break;
case DATE :
case YEARMONTH :
示例13: editcell
//.........这里部分代码省略.........
showall();
break;
case INTEREST : entercell(sys.cell);
status.interest=
inputreal(x,y,status.interest,5,2);
wait();
initdivmtx(0);
calcall();
if (sys.screen == SCREEN3) calcallvol();
else recalcvolvalues = TRUE;
showall();
break;
case DATE : entercell(sys.cell);
inputdate(x,y,sys.date);
wait();
initdates();
initsizepay();
calcdays();
initdivmtx(0);
calcall();
if (sys.screen == SCREEN3) calcallvol();
else recalcvolvalues = TRUE;
showall();
break;
case SHARESPER : entercell(sys.cell);
status.sizepay[y].sharesper=
inputinteger(x,y,status.sizepay[y].sharesper,4);
if (status.sizepay[y].sharesper < 1)
status.sizepay[y].sharesper = 1;
wait();
break;
case EXPIRYDAY : entercell(sys.cell);
sys.expiry[y].eday =inputinteger(x,y,sys.expiry[y].eday,2);
if (sys.expiry[y].eday < 1) sys.expiry[y].eday = 1;
else if (sys.expiry[y].eday > 31) sys.expiry[y].eday = 28;
wait();
initdates();
calcdays();
initdivmtx(0);
calcall();
tosavesys = TRUE;
showall();
break;
case DIVIDENDDAY : entercell(sys.cell);
status.sizepay[y].dday=inputinteger(x,y,status.sizepay[y].dday,2);
if (status.sizepay[y].dday < 0)
status.sizepay[y].dday = 0;
else if (status.sizepay[y].dday > 31)
status.sizepay[y].dday = 28;
wait();
calcdays();
initdivmtx(0);
calcall();
showrow(cell.row);
break;
case DIVIDENDCENTS : entercell(sys.cell);
status.sizepay[y].payout
= inputinteger(x,y,status.sizepay[y].payout,3);
if (status.sizepay[y].payout < 0)
status.sizepay[y].payout = 0;
wait();
initdivmtx(0);
calcall();
showrow(cell.row);
break;
case VOLC : getch();
break;
case VOLP : getch();
break;
case MARKETC : entercell(sys.cell);
if (status.stockprice != 4.0) exit(0);
status.data[cell.row-8].marketc =
inputreal(x,y,status.data[cell.row-8].marketc,8,sys.decimal);
if (status.data[cell.row-8].marketc < 0)
status.data[cell.row-8].marketc = 0;
wait();
status.data[cell.row-8].volc = invertvolc(cell.row);
calcoverval(cell.row);
showrow(cell.row);
break;
case MARKETP : entercell(sys.cell);
if (status.stockprice != 4.0) exit(0);
status.data[cell.row-8].marketp =
inputreal(x,y,status.data[cell.row-8].marketp,8,sys.decimal);
if (status.data[cell.row-8].marketp < 0)
status.data[cell.row-8].marketp = 0;
wait();
status.data[cell.row-8].volp = invertvolp(cell.row);
calcoverval(cell.row);
showrow(cell.row);
break;
}
entercell(cell);
totals();
showtotals();
if (status.stockprice != 4.0) exit(0);
ready();
ch = getch();
return(ch);
}
示例14: kforkexecac
//.........这里部分代码省略.........
a = args = UINT2PTR(stack);
stack = sysexecstack(stack, argc);
// XXX: look through math on this. look at ../../9/port/ exec.c
// YYY: this looks like a Jimism for 9k.
// DBG("kexec: ensuring the stack \n");
if(0)
if(stack-(argc+1)*sizeof(char**)-BIGPGSZ < sbase+ssize-4096)
error(Ebadexec);
argv = (char**)stack;
*--argv = nil;
// XXX: replace USTKTOP with a new variable representing the top of stack.
if(0)
for(i = 0; i < argc; i++){
*--argv = args + (USTKTOP-sbase+ssize);
args += strlen(args) + 1;
}
DBG("argsing\n");
n = args - a;
if(0)
if(n <= 0)
error(Egreg);
if(n > 128)
n = 128;
DBG("kexec: allocating args\n");
// XXX: hangs in smalloc, not sure why.
// args = smalloc(n);
// if(waserror()){
// DBG("erroring\n");
// free(args);
// nexterror();
// }
// DBG("kexec: moving args\n");
// memmove(args, a, n);
// if(0)
// while(n > 0 && (args[n-1] & 0xc0) == 0x80)
// n--;
// args[n-1] = '\0';
kstrdup(&p->text, "kexecproc");
p->args = nil;
//elem;
// elem = nil;
// p->args = args;
// p->nargs = n;
poperror(); /* p (m->externup->args) */
/*
qlock(&p->debug);
sysprocsetup(p);
qunlock(&p->debug);
*/
// why is this sched and not ureg?
p->sched.pc = entry;
// the real question here is how do you set up the stack?
p->sched.sp = PTR2UINT(stack-BY2SE);
p->sched.sp = STACKALIGN(p->sched.sp);
// XXX: what does it imply if you have a kproc that runs on an ac?
if(core > 0){
DBG("kexec: coring %d\n", core);
mp = p->ac;
mp->icc->flushtlb = 1;
mp->icc->rc = ICCOK;
DBG("kexec: exotic proc on cpu%d\n", mp->machno);
qlock(&p->debug);
if(waserror()){
DBG("kexec: had error");
qunlock(&p->debug);
nexterror();
}
p->nicc++;
p->state = Exotic;
p->psstate = 0;
DBG("kexec: unlocking");
qunlock(&p->debug);
poperror();
mfence();
mp->icc->fn = (void*)entry;
sched();
}else{
DBG("kexec: readying\n");
ready(p);
p->newtlb = 1;
mmuflush();
}
DBG("kforkexecac up %#p done\n"
"textsz %lx datasz %lx bsssz %lx hdrsz %lx\n"
"textlim %ullx datalim %ullx bsslim %ullx\n", m->externup,
textsz, datasz, bsssz, hdrsz, textlim, datalim, bsslim);
}
示例15: USED
void
runtime·chanrecv(ChanType *t, Hchan* c, byte *ep, bool *selected, bool *received)
{
SudoG *sg;
SudoG mysg;
G *gp;
if(runtime·gcwaiting)
runtime·gosched();
if(debug)
runtime·printf("chanrecv: chan=%p\n", c);
if(c == nil) {
USED(t);
if(selected != nil) {
*selected = false;
return;
}
g->status = Gwaiting;
g->waitreason = "chan receive (nil chan)";
runtime·gosched();
return; // not reached
}
runtime·lock(c);
if(c->dataqsiz > 0)
goto asynch;
if(c->closed)
goto closed;
sg = dequeue(&c->sendq);
if(sg != nil) {
runtime·unlock(c);
if(ep != nil)
c->elemalg->copy(c->elemsize, ep, sg->elem);
gp = sg->g;
gp->param = sg;
runtime·ready(gp);
if(selected != nil)
*selected = true;
if(received != nil)
*received = true;
return;
}
if(selected != nil) {
runtime·unlock(c);
*selected = false;
return;
}
mysg.elem = ep;
mysg.g = g;
mysg.selgen = NOSELGEN;
g->param = nil;
g->status = Gwaiting;
g->waitreason = "chan receive";
enqueue(&c->recvq, &mysg);
runtime·unlock(c);
runtime·gosched();
if(g->param == nil) {
runtime·lock(c);
if(!c->closed)
runtime·throw("chanrecv: spurious wakeup");
goto closed;
}
if(received != nil)
*received = true;
return;
asynch:
if(c->qcount <= 0) {
if(c->closed)
goto closed;
if(selected != nil) {
runtime·unlock(c);
*selected = false;
if(received != nil)
*received = false;
return;
}
mysg.g = g;
mysg.elem = nil;
mysg.selgen = NOSELGEN;
g->status = Gwaiting;
g->waitreason = "chan receive";
enqueue(&c->recvq, &mysg);
runtime·unlock(c);
runtime·gosched();
runtime·lock(c);
goto asynch;
}
//.........这里部分代码省略.........