本文整理汇总了C++中BLocker类的典型用法代码示例。如果您正苦于以下问题:C++ BLocker类的具体用法?C++ BLocker怎么用?C++ BLocker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BLocker类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getextmntent_haiku
int
getextmntent_haiku(int* cookie, struct extmnttab *mp, int len)
{
static BLocker extmntent_locker;
extmntent_locker.Lock();
BVolumeRoster roster;
BVolume volume;
int ret = -1;
roster.Rewind();
for (int i = 0; i <= *cookie; i++)
if (roster.GetNextVolume(&volume) != B_NO_ERROR)
return -1;
if (getmntent_haiku(cookie, (struct mnttab*)mp) == 0) {
mp->mnt_major = volume.Device();
mp->mnt_minor = volume.Device();
ret = 0;
}
extmntent_locker.Unlock();
return ret;
}
示例2:
Decoder *
mp3DecoderPlugin::NewDecoder(uint index)
{
static BLocker locker;
static bool initdone = false;
locker.Lock();
if (!initdone) {
InitMpgLib();
initdone = true;
}
locker.Unlock();
return new mp3Decoder;
}
示例3: getmntent_haiku
int
getmntent_haiku(int* cookie, struct mnttab* mp)
{
static BLocker mntent_locker;
mntent_locker.Lock();
int ret = -1;
BVolumeRoster roster;
char buf[B_PATH_NAME_LENGTH];
int buflen = 0;
BVolume volume;
BDirectory rootDir;
BEntry rootDirEntry;
BPath rootDirPath;
roster.Rewind();
for (int i = 0; i <= *cookie; i++)
if (roster.GetNextVolume(&volume) != B_NO_ERROR)
goto bail;
// volume name
volume.GetName(buf);
buflen = strlen(buf);
if (buflen == 0) {
buflen = strlen(MNTENT_MP_UNKNOWN);
strlcpy(buf, MNTENT_MP_UNKNOWN, buflen + 1);
}
mp->mnt_special = (char* )malloc(sizeof(char) * (buflen+1));
strlcpy(mp->mnt_special, buf, buflen+1);
// mount point
if (volume.GetRootDirectory(&rootDir) != B_OK ||
rootDir.GetEntry(&rootDirEntry) != B_OK ||
rootDirEntry.GetPath(&rootDirPath) != B_OK)
goto bail;
buflen = strlen(rootDirPath.Path());
mp->mnt_mountp = (char* )malloc(sizeof(char) * (buflen+1));
strlcpy(mp->mnt_mountp, rootDirPath.Path(), buflen + 1);
// partition type.
fs_info info;
if (fs_stat_dev(volume.Device(), &info) != B_OK)
goto bail;
buflen = strlen(info.fsh_name);
mp->mnt_fstype = (char* )malloc(sizeof(char) * (buflen+1));
strlcpy(mp->mnt_fstype, info.fsh_name, buflen+1);
// fs options. set default options for all file systems for now.
buflen = strlen(MNTENT_MP_DEFAULT_OPTS);
mp->mnt_mntopts = (char* )malloc(sizeof(char) * (buflen+2+1)); // extra space for ro/rw
strlcpy(mp->mnt_mntopts, MNTENT_MP_DEFAULT_OPTS, buflen + 2 + 1);
strcat(mp->mnt_mntopts, volume.IsReadOnly() ? ",ro":",rw");
// mount time. no idea how i can get this. set it to 0 for now.
buflen = 1;
mp->mnt_time = (char* )malloc(sizeof(char) * (buflen+1));
strlcpy(mp->mnt_time, "0", buflen + 1);
(*cookie)++;
ret = 0; /* success! */
bail:
mntent_locker.Unlock();
return ret;
}
示例4:
void
RegisterWindow(void)
{
sWindowLocker.Lock();
sWindowCount++;
sWindowLocker.Unlock();
}
示例5: output
static void
listener_output(syslog_message &message)
{
// compose the message to be sent to all listeners; just convert
// the syslog_message into a BMessage
BMessage output(SYSLOG_MESSAGE);
output.AddInt32("from", message.from);
output.AddInt32("when", message.when);
output.AddString("ident", message.ident);
output.AddString("message", message.message);
output.AddInt32("options", message.options);
output.AddInt32("priority", message.priority);
sLocker.Lock();
for (int32 i = sListeners.CountItems(); i-- > 0;) {
BMessenger *target = (BMessenger *)sListeners.ItemAt(i);
status_t status = target->SendMessage(&output);
if (status < B_OK) {
// remove targets once they can't be reached anymore
sListeners.RemoveItem(target);
}
}
sLocker.Unlock();
}
示例6: WatchNode
status_t WatchNode (node_ref node, uint32 flags, const BHandler *handler, const BLooper *looper)
{
/* Allocate a node monitor normally */
codeLocker.Lock();
status_t result = watch_node (&node, flags, handler, looper);
if (result == B_OK || result != B_NO_MEMORY)
{
codeLocker.Unlock();
return result;
}
/* Failed to start monitor, try to allocate more monitors */
result = NeedMoreNodeMonitors();
/* Failed to allocate more monitors */
if (result != B_OK)
{
codeLocker.Unlock();
return result;
}
/* Try again, this time with more node monitors */
codeLocker.Unlock();
return watch_node (&node, flags, handler, looper);
}
示例7: FindStatus
Status* FindStatus(BString abbreviation)
{
statLock.Lock();
Status *status = statusses[abbreviation];
statLock.Unlock();
return status;
}
示例8: Unlock
void GlobalMutex::Unlock()
{
// assert( g_cLock.LockingThread() == getpid() );
// assert( g_cLock.LockingThread() == GetCurLooper()->Thread() );
// assert( g_cLock.LockingThread() == find_thread(NULL) );
assert( g_cLock.IsLocked() );
g_cLock.Unlock();
}
示例9:
void
add_listener(BMessenger *messenger)
{
if (sLocker.Lock()) {
sListeners.AddItem(messenger);
sLocker.Unlock();
}
}
示例10: NeedMoreNodeMonitors
status_t NeedMoreNodeMonitors ()
{
/* Bump node monitor count up BY "bumpValue" */
codeLocker.Lock();
nodeCount += bumpValue;
codeLocker.Unlock();
return _kset_mon_limit_ (nodeCount);
}
示例11: DeleteStatusses
void DeleteStatusses()
{
statLock.Lock();
for (SI p = statusses.begin(); p != statusses.end(); ++p)
{
delete (*p).second;
}
statLock.Unlock();
}
示例12:
void
PObjectBroker::UnregisterObject(PObject *obj)
{
if (obj && !fQuitting)
{
sIDLock.Lock();
fObjectList->RemoveItem(obj,false);
sIDLock.Unlock();
}
}
示例13:
status_t
BMediaFormats::RewindFormats()
{
if (!sLock.IsLocked() || sLock.LockingThread() != find_thread(NULL)) {
// TODO: Shouldn't we simply drop into the debugger in this case?
return B_NOT_ALLOWED;
}
fIteratorIndex = 0;
return B_OK;
}
示例14:
void
BufferProc(void *cookie, void *buff, size_t len, const media_raw_audio_format &format)
{
if(settings.sound.s9x_mute) {
memset(buff, 0, len);
return;
}
sound_locker.Lock();
S9xMixSamples((uint8 *)buff,(so.sixteen_bit?so.buffer_size>>1:so.buffer_size));
sound_locker.Unlock();
}
示例15:
void
WPASupplicantApp::_NotifyInterfaceStateChanged(BMessage *message)
{
const wpa_supplicant *interface;
if (message->FindPointer("interface", (void **)&interface) != B_OK)
return;
if (!fWatchingEntryListLocker.Lock())
return;
for (int32 i = 0; i < fWatchingEntryList.CountItems(); i++) {
StateChangeWatchingEntry *entry = fWatchingEntryList.ItemAt(i);
if (entry->MessageReceived(interface, message)) {
delete fWatchingEntryList.RemoveItemAt(i);
i--;
}
}
fWatchingEntryListLocker.Unlock();
}